mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
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:
parent
4152868620
commit
3245d48b86
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) */
|
||||
|
@ -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",
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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 &&
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user