提交 1455a91b 编写于 作者: P Peter Krempa

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.
上级 be50137a
...@@ -1509,9 +1509,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src) ...@@ -1509,9 +1509,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src)
static int static int
qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
virQEMUDriverConfigPtr cfg, virBufferPtr buf)
virBufferPtr buf,
virQEMUCapsPtr qemuCaps)
{ {
int actualType = virStorageSourceGetActualType(disk->src); int actualType = virStorageSourceGetActualType(disk->src);
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
...@@ -1581,6 +1579,9 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, ...@@ -1581,6 +1579,9 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
virBufferAsprintf(buf, ",file.password-secret=%s", secinfo->s.aes.alias); virBufferAsprintf(buf, ",file.password-secret=%s", secinfo->s.aes.alias);
if (disk->src->debug)
virBufferAsprintf(buf, ",file.debug=%d", disk->src->debugLevel);
} else { } else {
if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops))) if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
goto cleanup; goto cleanup;
...@@ -1589,12 +1590,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, ...@@ -1589,12 +1590,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
} }
virBufferAddLit(buf, ","); 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) if (encinfo)
virQEMUBuildLuksOpts(buf, &disk->src->encryption->encinfo, virQEMUBuildLuksOpts(buf, &disk->src->encryption->encinfo,
encinfo->s.aes.alias); encinfo->s.aes.alias);
...@@ -1722,13 +1717,12 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, ...@@ -1722,13 +1717,12 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
char * char *
qemuBuildDriveStr(virDomainDiskDefPtr disk, qemuBuildDriveStr(virDomainDiskDefPtr disk,
virQEMUDriverConfigPtr cfg,
bool bootable, bool bootable,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
virBuffer opt = VIR_BUFFER_INITIALIZER; virBuffer opt = VIR_BUFFER_INITIALIZER;
if (qemuBuildDriveSourceStr(disk, cfg, &opt, qemuCaps) < 0) if (qemuBuildDriveSourceStr(disk, &opt) < 0)
goto error; goto error;
if (qemuDiskBusNeedsDeviceArg(disk->bus)) { if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
...@@ -2213,7 +2207,6 @@ qemuBuildDriveDevStr(const virDomainDef *def, ...@@ -2213,7 +2207,6 @@ qemuBuildDriveDevStr(const virDomainDef *def,
static int static int
qemuBuildDiskDriveCommandLine(virCommandPtr cmd, qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def, const virDomainDef *def,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
...@@ -2293,7 +2286,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, ...@@ -2293,7 +2286,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
virCommandAddArg(cmd, "-drive"); virCommandAddArg(cmd, "-drive");
if (!(optstr = qemuBuildDriveStr(disk, cfg, driveBoot, qemuCaps))) if (!(optstr = qemuBuildDriveStr(disk, driveBoot, qemuCaps)))
return -1; return -1;
virCommandAddArg(cmd, optstr); virCommandAddArg(cmd, optstr);
...@@ -10188,7 +10181,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, ...@@ -10188,7 +10181,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0)
goto error; goto error;
if (qemuBuildDiskDriveCommandLine(cmd, cfg, def, qemuCaps) < 0) if (qemuBuildDiskDriveCommandLine(cmd, def, qemuCaps) < 0)
goto error; goto error;
if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0)
......
...@@ -101,7 +101,6 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk); ...@@ -101,7 +101,6 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
/* Both legacy & current support */ /* Both legacy & current support */
char *qemuBuildDriveStr(virDomainDiskDefPtr disk, char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
virQEMUDriverConfigPtr cfg,
bool bootable, bool bootable,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);
......
...@@ -10520,5 +10520,12 @@ qemuDomainPrepareDiskSource(virConnectPtr conn, ...@@ -10520,5 +10520,12 @@ qemuDomainPrepareDiskSource(virConnectPtr conn,
if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0) if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
return -1; 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; return 0;
} }
...@@ -406,7 +406,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, ...@@ -406,7 +406,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
disk->info.alias) < 0) disk->info.alias) < 0)
goto error; goto error;
if (!(drivestr = qemuBuildDriveStr(disk, cfg, false, priv->qemuCaps))) if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
goto error; goto error;
if (!(drivealias = qemuAliasFromDisk(disk))) if (!(drivealias = qemuAliasFromDisk(disk)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册