[libvirt] [PATCH 1/8] domain: Add virDomainDefAddImplicitDevices
Cole Robinson
crobinso at redhat.com
Sun Mar 20 20:17:52 UTC 2016
On 03/14/2016 02:42 PM, John Ferlan wrote:
>
>
> On 03/08/2016 11:36 AM, Cole Robinson wrote:
>> It's just a combination of AddImplicitControllers, and AddConsoleCompat.
>> Every caller that wants ImplicitControllers also wants the ConsoleCompat
>> AFAICT, so lump them together. We also need it for future patches.
>> ---
>> src/conf/domain_conf.c | 19 ++++++++++++++-----
>> src/conf/domain_conf.h | 2 +-
>> src/libvirt_private.syms | 2 +-
>> src/qemu/qemu_driver.c | 6 +++---
>> src/vmx/vmx.c | 2 +-
>> src/vz/vz_sdk.c | 2 +-
>> 6 files changed, 21 insertions(+), 12 deletions(-)
>>
>
> Not an issue, but a note below...
>
> ACK -
>
Thanks, pushed now
> John
>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 39cedbd..40b1929 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -3842,9 +3842,6 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
>> if (virDomainDefPostParseMemory(def, parseFlags) < 0)
>> return -1;
>>
>> - if (virDomainDefAddConsoleCompat(def) < 0)
>> - return -1;
>> -
>> if (virDomainDefRejectDuplicateControllers(def) < 0)
>> return -1;
>>
>> @@ -3854,7 +3851,7 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
>> if (virDomainDefPostParseTimer(def) < 0)
>> return -1;
>>
>> - if (virDomainDefAddImplicitControllers(def) < 0)
>> + if (virDomainDefAddImplicitDevices(def) < 0)
>> return -1;
>>
>> /* clean up possibly duplicated metadata entries */
>> @@ -18289,7 +18286,7 @@ virDomainDefMaybeAddSmartcardController(virDomainDefPtr def)
>> * in the XML. This is for compat with existing apps which will
>> * not know/care about <controller> info in the XML
>> */
>> -int
>> +static int
>> virDomainDefAddImplicitControllers(virDomainDefPtr def)
>> {
>> if (virDomainDefAddDiskControllersForType(def,
>> @@ -18324,6 +18321,18 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def)
>> return 0;
>> }
>>
>> +int
>> +virDomainDefAddImplicitDevices(virDomainDefPtr def)
>> +{
>> + if (virDomainDefAddConsoleCompat(def) < 0)
>> + return -1;
>> +
>> + if (virDomainDefAddImplicitControllers(def) < 0)
>> + return -1;
>> +
>> + return 0;
>> +}
>> +
>> virDomainIOThreadIDDefPtr
>> virDomainIOThreadIDFind(virDomainDefPtr def,
>> unsigned int iothread_id)
>> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
>> index 06305f0..6f044d2 100644
>> --- a/src/conf/domain_conf.h
>> +++ b/src/conf/domain_conf.h
>> @@ -2697,7 +2697,7 @@ virDomainObjPtr virDomainObjParseFile(const char *filename,
>> bool virDomainDefCheckABIStability(virDomainDefPtr src,
>> virDomainDefPtr dst);
>>
>> -int virDomainDefAddImplicitControllers(virDomainDefPtr def);
>> +int virDomainDefAddImplicitDevices(virDomainDefPtr def);
>>
>> virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(virDomainDefPtr def,
>> unsigned int iothread_id);
>> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
>> index 3a1b9e1..5399117 100644
>> --- a/src/libvirt_private.syms
>> +++ b/src/libvirt_private.syms
>> @@ -200,7 +200,7 @@ virDomainControllerRemove;
>> virDomainControllerTypeToString;
>> virDomainCpuPlacementModeTypeFromString;
>> virDomainCpuPlacementModeTypeToString;
>> -virDomainDefAddImplicitControllers;
>> +virDomainDefAddImplicitDevices;
>> virDomainDefAddUSBController;
>> virDomainDefCheckABIStability;
>> virDomainDefCheckDuplicateDiskInfo;
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index 102fade..9c60518 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -7924,7 +7924,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
>> /* vmdef has the pointer. Generic codes for vmdef will do all jobs */
>> dev->data.disk = NULL;
>> if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO)
>> - if (virDomainDefAddImplicitControllers(vmdef) < 0)
>> + if (virDomainDefAddImplicitDevices(vmdef) < 0)
>> return -1;
>> if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
>> return -1;
>> @@ -7949,7 +7949,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
>> if (virDomainHostdevInsert(vmdef, hostdev))
>> return -1;
>> dev->data.hostdev = NULL;
>> - if (virDomainDefAddImplicitControllers(vmdef) < 0)
>> + if (virDomainDefAddImplicitDevices(vmdef) < 0)
>> return -1;
>> if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
>> return -1;
>> @@ -7991,7 +7991,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
>> if (qemuDomainChrInsert(vmdef, dev->data.chr) < 0)
>> return -1;
>> dev->data.chr = NULL;
>> - if (virDomainDefAddImplicitControllers(vmdef) < 0)
>> + if (virDomainDefAddImplicitDevices(vmdef) < 0)
>> return -1;
>> if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
>> return -1;
>> diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
>> index 4fd0a1d..893c77a 100644
>> --- a/src/vmx/vmx.c
>> +++ b/src/vmx/vmx.c
>> @@ -1691,7 +1691,7 @@ virVMXParseConfig(virVMXContext *ctx,
>> }
>>
>> /* def:controllers */
>> - if (virDomainDefAddImplicitControllers(def) < 0) {
>> + if (virDomainDefAddImplicitDevices(def) < 0) {
>> virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not add controllers"));
>
> Do we care about the error message here?
>
> Existing, but perhaps notable... Interesting order in vmx code to add
> implicit controller/devices before adding defined controller devices.
> Although I suppose that SCSI controller range check would need
> adjustment too.
>
I just left the error as is. I think the ideal thing would be to get most
callers to use virDomainDefAddImplicitDevices via virDomainDefPostParse rather
than calling it manually. There's a few other usages spread around too.
- Cole
More information about the libvir-list
mailing list