On 01/09/2012 07:29 AM, Osier Yang wrote:
If the domain is running, the live def is used to parse the device
XML, otherwise persistent def is used.
---
src/qemu/qemu_driver.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
Either the XML is valid on its own (it can be parsed into a domain_conf
structure and output again) or it is not; it should not depend on
whether it is also a subset of a specific domain, so I don't see how
deciding between live or persistent domain XML should come into play.
+static char *
+qemuDomainNormalizeDeviceXML(virDomainPtr dom,
+ const char *device_xml,
+ unsigned int flags)
+{
+ struct qemud_driver *driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ virDomainDefPtr persistentDef = NULL;
+ virDomainDefPtr def = NULL;
+ virDomainDeviceDefPtr dev = NULL;
+ char *ret = NULL;
Missing a virCheckFlags().
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ qemuDriverUnlock(driver);
Again, I don't see the point of a vm lookup; this should operate on just
the connection level.
+
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ qemuReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"),
uuidstr);
+ goto cleanup;
+ }
+
+ if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
+ &persistentDef) < 0)
+ goto cleanup;
+
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ def = vm->def;
+ } else {
+ def = persistentDef;
+ }
and that means that we should _not_ be checking for VIR_DOMAIN_AFFECT_*.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org