From 3245d48b86d55c2e3847828f8bca6125fe0d5aa7 Mon Sep 17 00:00:00 2001 From: Matt Coleman Date: Thu, 5 Nov 2020 22:32:37 -0500 Subject: [PATCH] domain_conf: make virDomainDiskSetDriver() void The function only returns zero or aborts, so it might as well be void. This has the added benefit of simplifying the code that calls it. Signed-off-by: Matt Coleman Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 3 +-- src/conf/domain_conf.h | 3 +-- src/libxl/libxl_conf.c | 2 +- src/libxl/libxl_domain.c | 5 ++--- src/libxl/libxl_driver.c | 3 +-- src/libxl/xen_xl.c | 12 ++++-------- src/libxl/xen_xm.c | 10 +++------- src/qemu/qemu_domain.c | 5 ++--- src/vz/vz_sdk.c | 3 +-- 9 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d84d0327ad..f05a6cb225 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2270,13 +2270,12 @@ virDomainDiskGetDriver(const virDomainDiskDef *def) } -int +void virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name) { char *tmp = g_strdup(name); g_free(def->driverName); def->driverName = tmp; - return 0; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9fc5841457..4cd6bcd01d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3043,8 +3043,7 @@ const char *virDomainDiskGetSource(virDomainDiskDef const *def); void virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src); void virDomainDiskEmptySource(virDomainDiskDefPtr def); const char *virDomainDiskGetDriver(const virDomainDiskDef *def); -int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name) - G_GNUC_WARN_UNUSED_RESULT; +void virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name); int virDomainDiskGetFormat(virDomainDiskDefPtr def); void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format); virDomainControllerDefPtr diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 43d23565f1..383f2295a2 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1237,7 +1237,7 @@ libxlUpdateDiskDef(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk) break; } if (driver) - ignore_value(virDomainDiskSetDriver(l_disk, driver)); + virDomainDiskSetDriver(l_disk, driver); } int diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index a3f362a0c8..3669b358f6 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -361,9 +361,8 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, /* for network-based disks, set 'qemu' as the default driver */ if (actual_type == VIR_STORAGE_TYPE_NETWORK) { - if (!virDomainDiskGetDriver(disk) && - virDomainDiskSetDriver(disk, "qemu") < 0) - return -1; + if (!virDomainDiskGetDriver(disk)) + virDomainDiskSetDriver(disk, "qemu"); } /* xl.cfg default format is raw. See xl-disk-configuration(5) */ diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 00a74dcb49..2195ecf47b 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4086,8 +4086,7 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev) virDomainDiskSetSource(orig, virDomainDiskGetSource(disk)); virDomainDiskSetType(orig, virDomainDiskGetType(disk)); virDomainDiskSetFormat(orig, virDomainDiskGetFormat(disk)); - if (virDomainDiskSetDriver(orig, virDomainDiskGetDriver(disk)) < 0) - return -1; + virDomainDiskSetDriver(orig, virDomainDiskGetDriver(disk)); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index d195f866c5..ed0ce77db4 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -725,8 +725,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def) disk->removable = libxldisk->removable; if (libxldisk->is_cdrom) { - if (virDomainDiskSetDriver(disk, "qemu") < 0) - goto fail; + virDomainDiskSetDriver(disk, "qemu"); virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; @@ -772,21 +771,18 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def) switch (libxldisk->backend) { case LIBXL_DISK_BACKEND_QDISK: case LIBXL_DISK_BACKEND_UNKNOWN: - if (virDomainDiskSetDriver(disk, "qemu") < 0) - goto fail; + virDomainDiskSetDriver(disk, "qemu"); if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_NONE) virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); break; case LIBXL_DISK_BACKEND_TAP: - if (virDomainDiskSetDriver(disk, "tap") < 0) - goto fail; + virDomainDiskSetDriver(disk, "tap"); virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); break; case LIBXL_DISK_BACKEND_PHY: - if (virDomainDiskSetDriver(disk, "phy") < 0) - goto fail; + virDomainDiskSetDriver(disk, "phy"); virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK); break; default: diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 283ed1ee8b..3e81c9ef0d 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -165,10 +165,7 @@ xenParseXMDisk(char *entry, int hvm) len = tmp - src; tmp = g_strndup(src, len); - if (virDomainDiskSetDriver(disk, tmp) < 0) { - VIR_FREE(tmp); - goto error; - } + virDomainDiskSetDriver(disk, tmp); VIR_FREE(tmp); /* Strip the prefix we found off the source file name */ @@ -208,9 +205,8 @@ xenParseXMDisk(char *entry, int hvm) } /* No source, or driver name, so fix to phy: */ - if (!virDomainDiskGetDriver(disk) && - virDomainDiskSetDriver(disk, "phy") < 0) - goto error; + if (!virDomainDiskGetDriver(disk)) + virDomainDiskSetDriver(disk, "phy"); /* phy: type indicates a block device */ virDomainDiskSetType(disk, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 02b5e7422c..70896ad80e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5086,9 +5086,8 @@ qemuDomainDeviceDiskDefPostParse(virDomainDiskDefPtr disk, unsigned int parseFlags) { /* set default disk types and drivers */ - if (!virDomainDiskGetDriver(disk) && - virDomainDiskSetDriver(disk, "qemu") < 0) - return -1; + if (!virDomainDiskGetDriver(disk)) + virDomainDiskSetDriver(disk, "qemu"); /* default disk format for drives */ if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE && diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 6a0ab5c862..cdd3f61ee1 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -698,8 +698,7 @@ prlsdkGetDiskInfo(vzDriverPtr driver, VIR_FREE(disk->serial); } - if (virDomainDiskSetDriver(disk, "vz") < 0) - goto cleanup; + virDomainDiskSetDriver(disk, "vz"); if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { pret = PrlVmDevHd_GetDiskSize(prldisk, &size);