mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: command: Properly format disk 'debug' attribute
Move the setup of the disk attribute to the disk source prepare function which will allow proper usage with JSON props and move the fallback (legacy) generating code into the block which is executed with legacy options. As a side-effect of this change we can clean up propagation of 'cfg' into the command generator. Also it's nice to see that the test output is the same even when the value is generated in a different place.
This commit is contained in:
parent
be50137aa0
commit
1455a91b33
@ -1509,9 +1509,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src)
|
||||
|
||||
static int
|
||||
qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
virBufferPtr buf,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
virBufferPtr buf)
|
||||
{
|
||||
int actualType = virStorageSourceGetActualType(disk->src);
|
||||
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
|
||||
@ -1581,6 +1579,9 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
||||
|
||||
if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
|
||||
virBufferAsprintf(buf, ",file.password-secret=%s", secinfo->s.aes.alias);
|
||||
|
||||
if (disk->src->debug)
|
||||
virBufferAsprintf(buf, ",file.debug=%d", disk->src->debugLevel);
|
||||
} else {
|
||||
if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
|
||||
goto cleanup;
|
||||
@ -1589,12 +1590,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
||||
}
|
||||
virBufferAddLit(buf, ",");
|
||||
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
|
||||
disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL))
|
||||
virBufferAsprintf(buf, "file.debug=%d,", cfg->glusterDebugLevel);
|
||||
}
|
||||
|
||||
if (encinfo)
|
||||
virQEMUBuildLuksOpts(buf, &disk->src->encryption->encinfo,
|
||||
encinfo->s.aes.alias);
|
||||
@ -1722,13 +1717,12 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
|
||||
|
||||
char *
|
||||
qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
bool bootable,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
if (qemuBuildDriveSourceStr(disk, cfg, &opt, qemuCaps) < 0)
|
||||
if (qemuBuildDriveSourceStr(disk, &opt) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
|
||||
@ -2213,7 +2207,6 @@ qemuBuildDriveDevStr(const virDomainDef *def,
|
||||
|
||||
static int
|
||||
qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
@ -2293,7 +2286,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
|
||||
|
||||
virCommandAddArg(cmd, "-drive");
|
||||
|
||||
if (!(optstr = qemuBuildDriveStr(disk, cfg, driveBoot, qemuCaps)))
|
||||
if (!(optstr = qemuBuildDriveStr(disk, driveBoot, qemuCaps)))
|
||||
return -1;
|
||||
|
||||
virCommandAddArg(cmd, optstr);
|
||||
@ -10188,7 +10181,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
|
||||
if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuBuildDiskDriveCommandLine(cmd, cfg, def, qemuCaps) < 0)
|
||||
if (qemuBuildDiskDriveCommandLine(cmd, def, qemuCaps) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0)
|
||||
|
@ -101,7 +101,6 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
|
||||
|
||||
/* Both legacy & current support */
|
||||
char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
bool bootable,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
|
||||
|
@ -10520,5 +10520,12 @@ qemuDomainPrepareDiskSource(virConnectPtr conn,
|
||||
if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
|
||||
return -1;
|
||||
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
|
||||
disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
|
||||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) {
|
||||
disk->src->debug = true;
|
||||
disk->src->debugLevel = cfg->glusterDebugLevel;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
|
||||
disk->info.alias) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(drivestr = qemuBuildDriveStr(disk, cfg, false, priv->qemuCaps)))
|
||||
if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
|
||||
goto error;
|
||||
|
||||
if (!(drivealias = qemuAliasFromDisk(disk)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user