The function is called on a virDomainDeviceInfo, so it should be declared along with it. Moving this function requires moving and making public virDomainDeviceCCWAddressIsValid() as well, but that's perfectly fine since the same reasoning above also applies to it, due to virDomainDeviceCCWAddress being (correctly) declared in device_conf. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- src/conf/device_conf.c | 36 ++++++++++++++++++++++++++++++++++++ src/conf/device_conf.h | 5 +++++ src/conf/domain_conf.c | 36 ------------------------------------ src/conf/domain_conf.h | 2 -- src/libvirt_private.syms | 3 ++- 5 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index dd381f303e..1db92aba4a 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -321,6 +321,42 @@ virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, return false; } +int +virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr) +{ + return addr->cssid <= VIR_DOMAIN_DEVICE_CCW_MAX_CSSID && + addr->ssid <= VIR_DOMAIN_DEVICE_CCW_MAX_SSID && + addr->devno <= VIR_DOMAIN_DEVICE_CCW_MAX_DEVNO; +} + +int +virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, + int type) +{ + if (info->type != type) + return 0; + + switch (info->type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: + return virPCIDeviceAddressIsValid(&info->addr.pci, false); + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: + return 1; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: + return 1; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: + return virDomainDeviceCCWAddressIsValid(&info->addr.ccw); + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: + return 1; + } + + return 0; +} + int virInterfaceLinkParseXML(xmlNodePtr node, virNetDevIfLinkPtr lnk) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 66a999760c..4a50c3183e 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -188,6 +188,9 @@ bool virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a, const virDomainDeviceInfo *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, + int type); + int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, bool report); bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr); @@ -205,6 +208,8 @@ int virPCIDeviceAddressFormat(virBufferPtr buf, bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, virPCIDeviceAddress *addr2); +int virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr); + int virInterfaceLinkParseXML(xmlNodePtr node, virNetDevIfLinkPtr lnk); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2a22978855..3cae6b2aeb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3586,42 +3586,6 @@ virDomainObjGetOneDef(virDomainObjPtr vm, return virDomainObjGetOneDefState(vm, flags, NULL); } - -static int -virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr) -{ - return addr->cssid <= VIR_DOMAIN_DEVICE_CCW_MAX_CSSID && - addr->ssid <= VIR_DOMAIN_DEVICE_CCW_MAX_SSID && - addr->devno <= VIR_DOMAIN_DEVICE_CCW_MAX_DEVNO; -} - -int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, - int type) -{ - if (info->type != type) - return 0; - - switch (info->type) { - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - return virPCIDeviceAddressIsValid(&info->addr.pci, false); - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: - return 1; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: - return 1; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: - return virDomainDeviceCCWAddressIsValid(&info->addr.ccw); - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: - return 1; - } - - return 0; -} - virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2a827a093f..3ff6eea117 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2911,8 +2911,6 @@ virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDef *def, virCapsPtr caps, virDomainXMLOptionPtr xmlopt); -int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, - int type); virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device); void virDomainTPMDefFree(virDomainTPMDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ae0c26ba99..78307885dc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -95,7 +95,9 @@ virCPUModeTypeToString; # conf/device_conf.h virDeviceInfoPCIAddressIsPresent; virDeviceInfoPCIAddressIsWanted; +virDomainDeviceAddressIsValid; virDomainDeviceAddressTypeToString; +virDomainDeviceCCWAddressIsValid; virDomainDeviceInfoAddressIsEqual; virDomainDeviceInfoCopy; virInterfaceLinkFormat; @@ -291,7 +293,6 @@ virDomainDefSetVcpusMax; virDomainDefValidate; virDomainDefVcpuOrderClear; virDomainDeleteConfig; -virDomainDeviceAddressIsValid; virDomainDeviceAliasIsUserAlias; virDomainDeviceDefCopy; virDomainDeviceDefFree; -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list