On 04/27/2016 02:29 PM, Cole Robinson wrote:
Rather than reimplement it. This will be needed in upcoming patches
---
src/conf/domain_conf.c | 2 +-
src/conf/domain_conf.h | 2 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_parse_command.c | 8 +++-----
4 files changed, 7 insertions(+), 6 deletions(-)
ACK for what's here... kudos for even considering qemu_parse_command -
it's certainly the forgotten step-child.
Would it be worth modifying qemuDomainFindOrCreateSCSIDiskController
too? I was just searching on other places where a VIR_ALLOC() was done
for a virDomainControllerDefPtr.
John
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b46cd2a..04817bd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1637,7 +1637,7 @@ virDomainDiskSetFormat(virDomainDiskDefPtr def, int format)
}
-static virDomainControllerDefPtr
+virDomainControllerDefPtr
virDomainControllerDefNew(virDomainControllerType type)
{
virDomainControllerDefPtr def;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ee66e6d..d98f052 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2558,6 +2558,8 @@ virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr
def,
int bus,
char *dst);
void virDomainControllerDefFree(virDomainControllerDefPtr def);
+virDomainControllerDefPtr
+virDomainControllerDefNew(virDomainControllerType type);
void virDomainFSDefFree(virDomainFSDefPtr def);
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
void virDomainNetDefFree(virDomainNetDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0de35ef..4d09dae 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -186,6 +186,7 @@ virDomainClockOffsetTypeToString;
virDomainConfigFile;
virDomainControllerAliasFind;
virDomainControllerDefFree;
+virDomainControllerDefNew;
virDomainControllerFind;
virDomainControllerFindByType;
virDomainControllerInsert;
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 79f5b92..455d515 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -2351,13 +2351,11 @@ qemuParseCommandLine(virCapsPtr caps,
/* ignore, generted on the fly */
} else if (STREQ(arg, "-usb")) {
virDomainControllerDefPtr ctldef;
- if (VIR_ALLOC(ctldef) < 0)
+ ctldef = virDomainControllerDefNew(VIR_DOMAIN_CONTROLLER_TYPE_USB);
+ if (!ctldef)
goto error;
- ctldef->type = VIR_DOMAIN_CONTROLLER_TYPE_USB;
- ctldef->idx = 0;
- ctldef->model = -1;
if (virDomainControllerInsert(def, ctldef) < 0) {
- VIR_FREE(ctldef);
+ virDomainControllerDefFree(ctldef);
goto error;
}
} else if (STREQ(arg, "-pidfile")) {