Since 0d70656afded, it starts to access the sysfs files to build
the qemu command line (by virSCSIDeviceGetSgName, which is find
out the scsi generic device name by adpater:bus:target:unit), there
is no way to work around, qemu wants to see the scsi generic device
like "/dev/sg6" anyway.
And I think it's not only the place which needs to access sysfs
files when building qemu command line in future.
As a solution, this introduces a new argument "sysfs_root" for
qemuBuildCommandLine, and thus the tests can feed the fake sysfs
root to it.
---
src/qemu/qemu_command.c | 3 ++-
src/qemu/qemu_command.h | 3 ++-
src/qemu/qemu_driver.c | 3 ++-
src/qemu/qemu_process.c | 3 ++-
tests/qemuxml2argvtest.c | 3 ++-
tests/qemuxmlnstest.c | 3 ++-
6 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5941f70..e054c1f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6400,7 +6400,8 @@ qemuBuildCommandLine(virConnectPtr conn,
const char *migrateFrom,
int migrateFd,
virDomainSnapshotObjPtr snapshot,
- enum virNetDevVPortProfileOp vmop)
+ enum virNetDevVPortProfileOp vmop,
+ const char *sysfs_root ATTRIBUTE_UNUSED)
{
virErrorPtr originalError = NULL;
int i, j;
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index ba42bb9..360d8cf 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -58,7 +58,8 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
const char *migrateFrom,
int migrateFd,
virDomainSnapshotObjPtr current_snapshot,
- enum virNetDevVPortProfileOp vmop)
+ enum virNetDevVPortProfileOp vmop,
+ const char *sysfs_root)
ATTRIBUTE_NONNULL(1);
/* Generate string for arch-specific '-device' parameter */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9453c22..80cdf45 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5339,7 +5339,8 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
if (!(cmd = qemuBuildCommandLine(conn, driver, def,
&monConfig, monitor_json, qemuCaps,
- NULL, -1, NULL,
VIR_NETDEV_VPORT_PROFILE_OP_NO_OP)))
+ NULL, -1, NULL, VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
+ NULL)))
goto cleanup;
ret = virCommandToString(cmd);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6499f4a..faeb02b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3619,7 +3619,8 @@ int qemuProcessStart(virConnectPtr conn,
VIR_DEBUG("Building emulator command line");
if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig,
priv->monJSON, priv->qemuCaps,
- migrateFrom, stdin_fd, snapshot, vmop)))
+ migrateFrom, stdin_fd, snapshot,
+ vmop, NULL)))
goto cleanup;
/* now that we know it is about to start call the hook if present */
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a2226f8..790857a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -157,7 +157,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (!(cmd = qemuBuildCommandLine(conn, &driver, vmdef, &monitor_chr,
(flags & FLAG_JSON), extraFlags,
migrateFrom, migrateFd, NULL,
- VIR_NETDEV_VPORT_PROFILE_OP_NO_OP))) {
+ VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
+ NULL))) {
if (flags & FLAG_EXPECT_FAILURE) {
ret = 0;
if (virTestGetDebug() > 1)
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 952b8e2..9d3d2a0 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -113,7 +113,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (!(cmd = qemuBuildCommandLine(conn, &driver,
vmdef, &monitor_chr, json, extraFlags,
migrateFrom, migrateFd, NULL,
- VIR_NETDEV_VPORT_PROFILE_OP_NO_OP)))
+ VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
+ NULL)))
goto fail;
if (!!virGetLastError() != expectError) {
--
1.8.1.4