mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
add virDomainVirtioSerialAddrSetCreateFromDomain
The address sets (pci, ccw, virtio serial) are currently cached in qemu private data, but all the information required to recreate these sets is in the domain definition. Therefore I am removing the redundant data and adding a way to recalculate these sets. Add a function that calculates the virtio serial address set from the domain definition. Credit goes to Cole Robinson.
This commit is contained in:
parent
cd6e4e5fe4
commit
40c284f0a6
@ -975,6 +975,37 @@ virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* virDomainVirtioSerialAddrSetCreateFromDomain
|
||||
+ *
|
||||
+ * @def: Domain def to introspect
|
||||
+ *
|
||||
+ * Inspect the domain definition and return an address set containing
|
||||
+ * every virtio serial address we find
|
||||
+ */
|
||||
virDomainVirtioSerialAddrSetPtr
|
||||
virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def)
|
||||
{
|
||||
virDomainVirtioSerialAddrSetPtr addrs = NULL;
|
||||
virDomainVirtioSerialAddrSetPtr ret = NULL;
|
||||
|
||||
if (!(addrs = virDomainVirtioSerialAddrSetCreate()))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainVirtioSerialAddrSetAddControllers(addrs, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve,
|
||||
addrs) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = addrs;
|
||||
addrs = NULL;
|
||||
cleanup:
|
||||
virDomainVirtioSerialAddrSetFree(addrs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
virDomainVirtioSerialAddrSetAutoaddController(virDomainDefPtr def,
|
||||
virDomainVirtioSerialAddrSetPtr addrs,
|
||||
|
@ -208,6 +208,9 @@ virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
void
|
||||
virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs);
|
||||
virDomainVirtioSerialAddrSetPtr
|
||||
virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
bool
|
||||
virDomainVirtioSerialAddrIsComplete(virDomainDeviceInfoPtr info);
|
||||
int
|
||||
|
@ -126,6 +126,7 @@ virDomainVirtioSerialAddrRelease;
|
||||
virDomainVirtioSerialAddrReserve;
|
||||
virDomainVirtioSerialAddrSetAddControllers;
|
||||
virDomainVirtioSerialAddrSetCreate;
|
||||
virDomainVirtioSerialAddrSetCreateFromDomain;
|
||||
virDomainVirtioSerialAddrSetFree;
|
||||
|
||||
|
||||
|
@ -114,14 +114,7 @@ qemuDomainAssignVirtioSerialAddresses(virDomainDefPtr def,
|
||||
virDomainVirtioSerialAddrSetPtr addrs = NULL;
|
||||
qemuDomainObjPrivatePtr priv = NULL;
|
||||
|
||||
if (!(addrs = virDomainVirtioSerialAddrSetCreate()))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainVirtioSerialAddrSetAddControllers(addrs, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve,
|
||||
addrs) < 0)
|
||||
if (!(addrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("Finished reserving existing ports");
|
||||
|
Loading…
Reference in New Issue
Block a user