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 <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Matt Coleman 2020-11-05 22:32:37 -05:00 committed by Michal Privoznik
parent 4152868620
commit 3245d48b86
9 changed files with 16 additions and 30 deletions

View File

@ -2270,13 +2270,12 @@ virDomainDiskGetDriver(const virDomainDiskDef *def)
} }
int void
virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name) virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
{ {
char *tmp = g_strdup(name); char *tmp = g_strdup(name);
g_free(def->driverName); g_free(def->driverName);
def->driverName = tmp; def->driverName = tmp;
return 0;
} }

View File

@ -3043,8 +3043,7 @@ const char *virDomainDiskGetSource(virDomainDiskDef const *def);
void virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src); void virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src);
void virDomainDiskEmptySource(virDomainDiskDefPtr def); void virDomainDiskEmptySource(virDomainDiskDefPtr def);
const char *virDomainDiskGetDriver(const virDomainDiskDef *def); const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name) void virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name);
G_GNUC_WARN_UNUSED_RESULT;
int virDomainDiskGetFormat(virDomainDiskDefPtr def); int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format); void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
virDomainControllerDefPtr virDomainControllerDefPtr

View File

@ -1237,7 +1237,7 @@ libxlUpdateDiskDef(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
break; break;
} }
if (driver) if (driver)
ignore_value(virDomainDiskSetDriver(l_disk, driver)); virDomainDiskSetDriver(l_disk, driver);
} }
int int

View File

@ -361,9 +361,8 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
/* for network-based disks, set 'qemu' as the default driver */ /* for network-based disks, set 'qemu' as the default driver */
if (actual_type == VIR_STORAGE_TYPE_NETWORK) { if (actual_type == VIR_STORAGE_TYPE_NETWORK) {
if (!virDomainDiskGetDriver(disk) && if (!virDomainDiskGetDriver(disk))
virDomainDiskSetDriver(disk, "qemu") < 0) virDomainDiskSetDriver(disk, "qemu");
return -1;
} }
/* xl.cfg default format is raw. See xl-disk-configuration(5) */ /* xl.cfg default format is raw. See xl-disk-configuration(5) */

View File

@ -4086,8 +4086,7 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
virDomainDiskSetSource(orig, virDomainDiskGetSource(disk)); virDomainDiskSetSource(orig, virDomainDiskGetSource(disk));
virDomainDiskSetType(orig, virDomainDiskGetType(disk)); virDomainDiskSetType(orig, virDomainDiskGetType(disk));
virDomainDiskSetFormat(orig, virDomainDiskGetFormat(disk)); virDomainDiskSetFormat(orig, virDomainDiskGetFormat(disk));
if (virDomainDiskSetDriver(orig, virDomainDiskGetDriver(disk)) < 0) virDomainDiskSetDriver(orig, virDomainDiskGetDriver(disk));
return -1;
break; break;
default: default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",

View File

@ -725,8 +725,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
disk->removable = libxldisk->removable; disk->removable = libxldisk->removable;
if (libxldisk->is_cdrom) { if (libxldisk->is_cdrom) {
if (virDomainDiskSetDriver(disk, "qemu") < 0) virDomainDiskSetDriver(disk, "qemu");
goto fail;
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE);
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
@ -772,21 +771,18 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
switch (libxldisk->backend) { switch (libxldisk->backend) {
case LIBXL_DISK_BACKEND_QDISK: case LIBXL_DISK_BACKEND_QDISK:
case LIBXL_DISK_BACKEND_UNKNOWN: case LIBXL_DISK_BACKEND_UNKNOWN:
if (virDomainDiskSetDriver(disk, "qemu") < 0) virDomainDiskSetDriver(disk, "qemu");
goto fail;
if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_NONE) if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_NONE)
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE);
break; break;
case LIBXL_DISK_BACKEND_TAP: case LIBXL_DISK_BACKEND_TAP:
if (virDomainDiskSetDriver(disk, "tap") < 0) virDomainDiskSetDriver(disk, "tap");
goto fail;
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE);
break; break;
case LIBXL_DISK_BACKEND_PHY: case LIBXL_DISK_BACKEND_PHY:
if (virDomainDiskSetDriver(disk, "phy") < 0) virDomainDiskSetDriver(disk, "phy");
goto fail;
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK); virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
break; break;
default: default:

View File

@ -165,10 +165,7 @@ xenParseXMDisk(char *entry, int hvm)
len = tmp - src; len = tmp - src;
tmp = g_strndup(src, len); tmp = g_strndup(src, len);
if (virDomainDiskSetDriver(disk, tmp) < 0) { virDomainDiskSetDriver(disk, tmp);
VIR_FREE(tmp);
goto error;
}
VIR_FREE(tmp); VIR_FREE(tmp);
/* Strip the prefix we found off the source file name */ /* 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: */ /* No source, or driver name, so fix to phy: */
if (!virDomainDiskGetDriver(disk) && if (!virDomainDiskGetDriver(disk))
virDomainDiskSetDriver(disk, "phy") < 0) virDomainDiskSetDriver(disk, "phy");
goto error;
/* phy: type indicates a block device */ /* phy: type indicates a block device */
virDomainDiskSetType(disk, virDomainDiskSetType(disk,

View File

@ -5086,9 +5086,8 @@ qemuDomainDeviceDiskDefPostParse(virDomainDiskDefPtr disk,
unsigned int parseFlags) unsigned int parseFlags)
{ {
/* set default disk types and drivers */ /* set default disk types and drivers */
if (!virDomainDiskGetDriver(disk) && if (!virDomainDiskGetDriver(disk))
virDomainDiskSetDriver(disk, "qemu") < 0) virDomainDiskSetDriver(disk, "qemu");
return -1;
/* default disk format for drives */ /* default disk format for drives */
if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE && if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE &&

View File

@ -698,8 +698,7 @@ prlsdkGetDiskInfo(vzDriverPtr driver,
VIR_FREE(disk->serial); VIR_FREE(disk->serial);
} }
if (virDomainDiskSetDriver(disk, "vz") < 0) virDomainDiskSetDriver(disk, "vz");
goto cleanup;
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
pret = PrlVmDevHd_GetDiskSize(prldisk, &size); pret = PrlVmDevHd_GetDiskSize(prldisk, &size);