mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
qemu: Use qemuAliasFromDisk instead of qemuDeviceDriveHostAlias
Since we already have a function that will generate the drivestr from the alias, let's use it and remove the qemuDeviceDriveHostAlias. Move the QEMU_DRIVE_HOST_PREFIX definition into qemu_alias.h Also alter qemuAliasFromDisk to use the QEMU_DRIVE_HOST_PREFIX instead of "drive-%s".
This commit is contained in:
parent
30c3982bda
commit
13effcafd2
@ -451,17 +451,26 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
|
||||
}
|
||||
|
||||
|
||||
/* qemuAliasFromDisk
|
||||
* @disk: Pointer to a disk definition
|
||||
*
|
||||
* Generate and return an alias for the device disk '-drive'
|
||||
*
|
||||
* Returns NULL with error or a string containing the alias
|
||||
*/
|
||||
char *
|
||||
qemuAliasFromDisk(const virDomainDiskDef *disk)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if (!disk->info.alias) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s", _("disk does not have an alias"));
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("disk does not have an alias"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ignore_value(virAsprintf(&ret, "drive-%s", disk->info.alias));
|
||||
ignore_value(virAsprintf(&ret, "%s%s", QEMU_DRIVE_HOST_PREFIX,
|
||||
disk->info.alias));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
# include "qemu_domain.h"
|
||||
# include "qemu_domain_address.h"
|
||||
|
||||
# define QEMU_DRIVE_HOST_PREFIX "drive-"
|
||||
|
||||
int qemuAssignDeviceChrAlias(virDomainDefPtr def,
|
||||
virDomainChrDefPtr chr,
|
||||
ssize_t idx);
|
||||
|
@ -274,17 +274,6 @@ qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
|
||||
}
|
||||
|
||||
|
||||
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if (virAsprintf(&ret, "%s%s",
|
||||
QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0)
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildDeviceAddressStr(virBufferPtr buf,
|
||||
const virDomainDef *domainDef,
|
||||
|
@ -37,7 +37,6 @@
|
||||
/* Config type for XML import/export conversions */
|
||||
# define QEMU_CONFIG_FORMAT_ARGV "qemu-argv"
|
||||
|
||||
# define QEMU_DRIVE_HOST_PREFIX "drive-"
|
||||
# define QEMU_FSDEV_HOST_PREFIX "fsdev-"
|
||||
|
||||
# define QEMU_BLOCK_IOTUNE_MAX 1000000000000000LL
|
||||
|
@ -229,7 +229,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
|
||||
if (qemuDomainPrepareDisk(driver, vm, disk, newsrc, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(driveAlias = qemuDeviceDriveHostAlias(disk)))
|
||||
if (!(driveAlias = qemuAliasFromDisk(disk)))
|
||||
goto error;
|
||||
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
@ -369,7 +369,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
|
||||
if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
|
||||
goto error;
|
||||
|
||||
if (!(drivealias = qemuDeviceDriveHostAlias(disk)))
|
||||
if (!(drivealias = qemuAliasFromDisk(disk)))
|
||||
goto error;
|
||||
|
||||
if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "qemu_domain.h"
|
||||
#include "qemu_process.h"
|
||||
#include "qemu_capabilities.h"
|
||||
#include "qemu_command.h"
|
||||
#include "qemu_alias.h"
|
||||
#include "qemu_cgroup.h"
|
||||
#include "qemu_hotplug.h"
|
||||
#include "qemu_blockjob.h"
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include "qemu_monitor_text.h"
|
||||
#include "qemu_monitor_json.h"
|
||||
#include "qemu_command.h"
|
||||
#include "qemu_alias.h"
|
||||
#include "qemu_parse_command.h"
|
||||
#include "qemu_capabilities.h"
|
||||
#include "viralloc.h"
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "qemu_monitor_text.h"
|
||||
#include "qemu_command.h"
|
||||
#include "qemu_alias.h"
|
||||
#include "c-ctype.h"
|
||||
#include "c-strcasestr.h"
|
||||
#include "viralloc.h"
|
||||
|
Loading…
Reference in New Issue
Block a user