diff mbox

[1/3] qemu: parse: Use virControllerDefNew

Message ID febfd4305cdd90d3bfe4dbb392ce77ab534af648.1461781613.git.crobinso@redhat.com
State Accepted
Commit 345d2ab488675b22f795c5b70f320cab92918e83
Headers show

Commit Message

Cole Robinson April 27, 2016, 6:29 p.m. UTC
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(-)

-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Cole Robinson May 2, 2016, 11:47 p.m. UTC | #1
On 05/02/2016 07:44 PM, John Ferlan wrote:
> 

> 

> 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.

> 


In truth I didn't intentionally consider it... later patches break the test
suite without this :)

> Would it be worth modifying qemuDomainFindOrCreateSCSIDiskController

> too?  I was just searching on other places where a VIR_ALLOC() was done

> for a virDomainControllerDefPtr.

> 


It's the 'more correct' thing to do but won't have any real functional impact,
since ControllerDefNew is only needed for virtio-serial and (now) usb controllers

- Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

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")) {