提交 40c284f0 编写于 作者: T Tomasz Flendrich 提交者: Martin Kletzander

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.
上级 cd6e4e5f
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册