[libvirt] [PATCH 0/3] Fix the build failure

As exposed by [1], qemuxml2argvtest fails because of it tries to access non-existing sysfs files when building qemu command for scsi-generic device. This creates "tests/sysfsroot", uses it as the fake sysfs root, any future sysfs test input files should be put into it. [1] https://www.redhat.com/archives/libvir-list/2013-May/msg00923.html Osier Yang (3): qemu: Allow to specify the sysfs root for qemuBuildCommandLine tests: Feed the fake sysfs root to qemuBuildCommandLine tests: Move fchostdata into sysfsroot src/qemu/qemu_cgroup.c | 3 +- src/qemu/qemu_command.c | 12 +++-- src/qemu/qemu_command.h | 6 ++- src/qemu/qemu_driver.c | 3 +- src/qemu/qemu_hostdev.c | 9 ++-- src/qemu/qemu_hotplug.c | 4 +- src/qemu/qemu_process.c | 3 +- src/security/security_dac.c | 6 ++- src/security/security_selinux.c | 6 ++- src/util/virscsi.c | 51 ++++++++++++++++++---- src/util/virscsi.h | 6 ++- tests/Makefile.am | 2 +- tests/fchostdata/fc_host/host4/fabric_name | 1 - tests/fchostdata/fc_host/host4/max_npiv_vports | 1 - tests/fchostdata/fc_host/host4/node_name | 1 - tests/fchostdata/fc_host/host4/npiv_vports_inuse | 1 - tests/fchostdata/fc_host/host4/port_name | 1 - tests/fchostdata/fc_host/host4/port_state | 1 - tests/fchostdata/fc_host/host4/vport_create | 0 tests/fchostdata/fc_host/host4/vport_delete | 0 tests/fchostdata/fc_host/host5/fabric_name | 1 - tests/fchostdata/fc_host/host5/max_npiv_vports | 1 - tests/fchostdata/fc_host/host5/node_name | 1 - tests/fchostdata/fc_host/host5/npiv_vports_inuse | 1 - tests/fchostdata/fc_host/host5/port_name | 1 - tests/fchostdata/fc_host/host5/port_state | 1 - tests/fchostdata/fc_host/host5/vport_create | 0 tests/fchostdata/fc_host/host5/vport_delete | 0 tests/fchosttest.c | 2 +- tests/qemuxml2argvtest.c | 5 ++- tests/qemuxmlnstest.c | 3 +- .../bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev | 1 + tests/sysfsroot/class/fc_host/host4/fabric_name | 1 + .../sysfsroot/class/fc_host/host4/max_npiv_vports | 1 + tests/sysfsroot/class/fc_host/host4/node_name | 1 + .../class/fc_host/host4/npiv_vports_inuse | 1 + tests/sysfsroot/class/fc_host/host4/port_name | 1 + tests/sysfsroot/class/fc_host/host4/port_state | 1 + tests/sysfsroot/class/fc_host/host4/vport_create | 0 tests/sysfsroot/class/fc_host/host4/vport_delete | 0 tests/sysfsroot/class/fc_host/host5/fabric_name | 1 + .../sysfsroot/class/fc_host/host5/max_npiv_vports | 1 + tests/sysfsroot/class/fc_host/host5/node_name | 1 + .../class/fc_host/host5/npiv_vports_inuse | 1 + tests/sysfsroot/class/fc_host/host5/port_name | 1 + tests/sysfsroot/class/fc_host/host5/port_state | 1 + tests/sysfsroot/class/fc_host/host5/vport_create | 0 tests/sysfsroot/class/fc_host/host5/vport_delete | 0 48 files changed, 101 insertions(+), 45 deletions(-) delete mode 100644 tests/fchostdata/fc_host/host4/fabric_name delete mode 100644 tests/fchostdata/fc_host/host4/max_npiv_vports delete mode 100644 tests/fchostdata/fc_host/host4/node_name delete mode 100644 tests/fchostdata/fc_host/host4/npiv_vports_inuse delete mode 100644 tests/fchostdata/fc_host/host4/port_name delete mode 100644 tests/fchostdata/fc_host/host4/port_state delete mode 100644 tests/fchostdata/fc_host/host4/vport_create delete mode 100644 tests/fchostdata/fc_host/host4/vport_delete delete mode 100644 tests/fchostdata/fc_host/host5/fabric_name delete mode 100644 tests/fchostdata/fc_host/host5/max_npiv_vports delete mode 100644 tests/fchostdata/fc_host/host5/node_name delete mode 100644 tests/fchostdata/fc_host/host5/npiv_vports_inuse delete mode 100644 tests/fchostdata/fc_host/host5/port_name delete mode 100644 tests/fchostdata/fc_host/host5/port_state delete mode 100644 tests/fchostdata/fc_host/host5/vport_create delete mode 100644 tests/fchostdata/fc_host/host5/vport_delete create mode 100644 tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev create mode 100644 tests/sysfsroot/class/fc_host/host4/fabric_name create mode 100644 tests/sysfsroot/class/fc_host/host4/max_npiv_vports create mode 100644 tests/sysfsroot/class/fc_host/host4/node_name create mode 100644 tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse create mode 100644 tests/sysfsroot/class/fc_host/host4/port_name create mode 100644 tests/sysfsroot/class/fc_host/host4/port_state create mode 100644 tests/sysfsroot/class/fc_host/host4/vport_create create mode 100644 tests/sysfsroot/class/fc_host/host4/vport_delete create mode 100644 tests/sysfsroot/class/fc_host/host5/fabric_name create mode 100644 tests/sysfsroot/class/fc_host/host5/max_npiv_vports create mode 100644 tests/sysfsroot/class/fc_host/host5/node_name create mode 100644 tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse create mode 100644 tests/sysfsroot/class/fc_host/host5/port_name create mode 100644 tests/sysfsroot/class/fc_host/host5/port_state create mode 100644 tests/sysfsroot/class/fc_host/host5/vport_create create mode 100644 tests/sysfsroot/class/fc_host/host5/vport_delete -- 1.8.1.4

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

On Wed, May 15, 2013 at 06:52:44PM +0800, Osier Yang wrote:
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.
IMHO it would be nicer to detach the command line generator code from any use of sysfs in this case. Instead of having QEMU call virSCSIDeviceGetSgName() directly, pass in a callback for it to use to resolve the device path. eg typedef char *(*qemuGetSCSIDevice)(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit); the qemuProcessStart code can pass in an impl of that callback which calls virSCSIDeviceGetSgName(), while the test suite can pass in an impl which returns a hard-coded device string. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Wed, May 15, 2013 at 12:07:42PM +0100, Daniel P. Berrange wrote:
On Wed, May 15, 2013 at 06:52:44PM +0800, Osier Yang wrote:
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.
IMHO it would be nicer to detach the command line generator code from any use of sysfs in this case.
Instead of having QEMU call virSCSIDeviceGetSgName() directly, pass in a callback for it to use to resolve the device path.
eg
typedef char *(*qemuGetSCSIDevice)(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit);
the qemuProcessStart code can pass in an impl of that callback which calls virSCSIDeviceGetSgName(), while the test suite can pass in an impl which returns a hard-coded device string.
In fact there are probably other cases where we should pass in callbacks like this to the QEMU command line builder. Instead of adding many parameters to the API, we could provide a struct containing all the various callbacks needed in one go. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 15/05/13 19:09, Daniel P. Berrange wrote:
On Wed, May 15, 2013 at 12:07:42PM +0100, Daniel P. Berrange wrote:
On Wed, May 15, 2013 at 06:52:44PM +0800, Osier Yang wrote:
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. IMHO it would be nicer to detach the command line generator code from any use of sysfs in this case.
Instead of having QEMU call virSCSIDeviceGetSgName() directly, pass in a callback for it to use to resolve the device path.
eg
typedef char *(*qemuGetSCSIDevice)(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit);
Nice idea.
the qemuProcessStart code can pass in an impl of that callback
I guess you meant qemuBuildCommandLine or so, tests won't call qemuProcessStart. to start the guest.
which calls virSCSIDeviceGetSgName(), while the test suite can pass in an impl which returns a hard-coded device string. In fact there are probably other cases where we should pass in callbacks like this to the QEMU command line builder. Instead of adding many parameters to the API, we could provide a struct
Agreed, many params is always not good. .
containing all the various callbacks needed in one go.
Daniel
Osier

On 05/15/2013 07:23 AM, Osier Yang wrote:
On 15/05/13 19:09, Daniel P. Berrange wrote:
On Wed, May 15, 2013 at 12:07:42PM +0100, Daniel P. Berrange wrote:
On Wed, May 15, 2013 at 06:52:44PM +0800, Osier Yang wrote:
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. IMHO it would be nicer to detach the command line generator code from any use of sysfs in this case.
Instead of having QEMU call virSCSIDeviceGetSgName() directly, pass in a callback for it to use to resolve the device path.
eg
typedef char *(*qemuGetSCSIDevice)(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit);
Nice idea.
the qemuProcessStart code can pass in an impl of that callback
I guess you meant qemuBuildCommandLine or so, tests won't call qemuProcessStart. to start the guest.
But qemuProcessStart() calls qemuBuildCommandLine().
which calls virSCSIDeviceGetSgName(), while the test suite can pass in an impl which returns a hard-coded device string. In fact there are probably other cases where we should pass in callbacks like this to the QEMU command line builder.
In that same category, the calls to qemuNetworkIfaceConnect, qemuPhysIfaceConnect, and qemuOpenVhostNet (and the "vmop" param to qemuBuildCommandLine()) have been bothering me for awhile, but instead of a callback sent to qemuBuildCommandLine(), I was considering the more direct idea of opening all the sockets before even calling qemuBuildCommandLine() and sending them in the arglist "somehow"[*] (rather than sending in a pointer to a callback that opens the fd's and passes them back, which gets a bit confusing if you're not intimately familiar with the code). [*] I *think* a reasonable way to do this would be to add alist of tap fd's and a hidden vhost-net fd) to the virActualNetDef that is part of every virNetDef, then populate it as a part of networkAllocateActualDevice() (which could probably do with a name change). This would have the side effect of consolidating all network device setup into the network driver, thus making it simpler to split it off into its own service.
Instead of adding many parameters to the API, we could provide a struct
Agreed, many params is always not good. .
containing all the various callbacks needed in one go.
Daniel
Maybe each device object could have a "hidden" part (i.e. not necessarily visible in the XML) that can be setup before calling qemuBuildCommandLine(), and qemuBuildCommandline could use that info if it's there, otherwise fills in "null" args on the commandline. I'm not against using a callback when it's appropriate, but I think they hinder proper understanding of code by newcomers, and should be used sparingly unless necessary.

On 16/05/13 01:09, Laine Stump wrote:
On 05/15/2013 07:23 AM, Osier Yang wrote:
On 15/05/13 19:09, Daniel P. Berrange wrote:
On Wed, May 15, 2013 at 12:07:42PM +0100, Daniel P. Berrange wrote:
On Wed, May 15, 2013 at 06:52:44PM +0800, Osier Yang wrote:
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. IMHO it would be nicer to detach the command line generator code from any use of sysfs in this case.
Instead of having QEMU call virSCSIDeviceGetSgName() directly, pass in a callback for it to use to resolve the device path.
eg
typedef char *(*qemuGetSCSIDevice)(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit); Nice idea.
the qemuProcessStart code can pass in an impl of that callback I guess you meant qemuBuildCommandLine or so, tests won't call qemuProcessStart. to start the guest. But qemuProcessStart() calls qemuBuildCommandLine().
Yeah, but tests will just involke qemuBuildCommandLine.
which calls virSCSIDeviceGetSgName(), while the test suite can pass in an impl which returns a hard-coded device string. In fact there are probably other cases where we should pass in callbacks like this to the QEMU command line builder.
In that same category, the calls to qemuNetworkIfaceConnect, qemuPhysIfaceConnect, and qemuOpenVhostNet (and the "vmop" param to qemuBuildCommandLine()) have been bothering me for awhile, but instead
yeah, I noticed them when making the patches. And I intended to clean up them using callbacks, fortunately, I didn't do it before the agreement.
of a callback sent to qemuBuildCommandLine(), I was considering the more direct idea of opening all the sockets before even calling qemuBuildCommandLine() and sending them in the arglist "somehow"[*] (rather than sending in a pointer to a callback that opens the fd's and passes them back, which gets a bit confusing if you're not intimately familiar with the code).
[*] I *think* a reasonable way to do this would be to add alist of tap fd's and a hidden vhost-net fd) to the virActualNetDef that is part of every virNetDef, then populate it as a part of networkAllocateActualDevice() (which could probably do with a name change). This would have the side effect of consolidating all network
IMHO the "def" struct should *only* keep configuration related stuffs, and it doesn't resolve the build failure, as the required command line string should be got in run-time anyway.
device setup into the network driver, thus making it simpler to split it off into its own service.
Instead of adding many parameters to the API, we could provide a struct Agreed, many params is always not good. .
containing all the various callbacks needed in one go.
Daniel Maybe each device object could have a "hidden" part (i.e. not necessarily visible in the XML) that can be setup before calling qemuBuildCommandLine(), and qemuBuildCommandline could use that info if it's there, otherwise fills in "null" args on the commandline.
Oh, you have a solution (the "null"). Putting /dev/null in the scsi-generic args files works (basicly it's similar with hard-code a "/dev/sg*" in the qemuxml2argvtest.c), but looks strange.
I'm not against using a callback when it's appropriate, but I think they hinder proper understanding of code by newcomers, and should be used sparingly unless necessary.

On Wed, May 15, 2013 at 01:09:44PM -0400, Laine Stump wrote:
On 05/15/2013 07:23 AM, Osier Yang wrote:
On 15/05/13 19:09, Daniel P. Berrange wrote:
Instead of adding many parameters to the API, we could provide a struct
Agreed, many params is always not good. .
containing all the various callbacks needed in one go.
Daniel
Maybe each device object could have a "hidden" part (i.e. not necessarily visible in the XML) that can be setup before calling qemuBuildCommandLine(), and qemuBuildCommandline could use that info if it's there, otherwise fills in "null" args on the commandline.
I'm not against using a callback when it's appropriate, but I think they hinder proper understanding of code by newcomers, and should be used sparingly unless necessary.
I'm strongly against adding any driver specific data to the "def" objects. They should be exclusively used for representing the XML configuration data, that is agnostic to any particular driver. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Wed, May 15, 2013 at 06:52:44PM +0800, Osier Yang wrote:
Since 0d70656afded, it starts to access the sysfs files to build the qemu command line (by virSCSIDeviceGetSgName, which is find
I'm not a native speaker but s/which is/to/ sounds better to me.
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
ACK. -- Guido
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 15/05/13 21:18, Guido Günther wrote:
On Wed, May 15, 2013 at 06:52:44PM +0800, Osier Yang wrote:
Since 0d70656afded, it starts to access the sysfs files to build the qemu command line (by virSCSIDeviceGetSgName, which is find I'm not a native speaker but
s/which is/to/
sounds better to me.
Thanks for the reviewing, but as Daniel suggested, callback structs is the nicer method, I posted v2. Osier

This creates a new directory "sysfsroot" under "tests", any sysfs test input files should be put into it in future. Currently only the scsi-generic tests need to use it, so only one file path is created (bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev). --- src/qemu/qemu_cgroup.c | 3 +- src/qemu/qemu_command.c | 11 +++-- src/qemu/qemu_command.h | 3 +- src/qemu/qemu_hostdev.c | 9 ++-- src/qemu/qemu_hotplug.c | 4 +- src/security/security_dac.c | 6 ++- src/security/security_selinux.c | 6 ++- src/util/virscsi.c | 51 ++++++++++++++++++---- src/util/virscsi.h | 6 ++- tests/qemuxml2argvtest.c | 4 +- .../bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev | 1 + 11 files changed, 77 insertions(+), 27 deletions(-) create mode 100644 tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index aaf94cf..55593e2 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -321,7 +321,8 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly)) == NULL) + dev->readonly, + NULL)) == NULL) goto cleanup; if (virSCSIDeviceFileIterate(scsi, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e054c1f..9f49a7d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4746,7 +4746,8 @@ qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev) char * qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, - virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED) + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, + const char *sysfs_root) { virBuffer buf = VIR_BUFFER_INITIALIZER; char *sg = NULL; @@ -4754,7 +4755,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, if (!(sg = virSCSIDeviceGetSgName(dev->source.subsys.u.scsi.adapter, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, - dev->source.subsys.u.scsi.unit))) { + dev->source.subsys.u.scsi.unit, + sysfs_root))) { goto error; } @@ -6401,7 +6403,7 @@ qemuBuildCommandLine(virConnectPtr conn, int migrateFd, virDomainSnapshotObjPtr snapshot, enum virNetDevVPortProfileOp vmop, - const char *sysfs_root ATTRIBUTE_UNUSED) + const char *sysfs_root) { virErrorPtr originalError = NULL; int i, j; @@ -8213,7 +8215,8 @@ qemuBuildCommandLine(virConnectPtr conn, char *drvstr; virCommandAddArg(cmd, "-drive"); - if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps))) + if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps, + sysfs_root))) goto error; virCommandAddArg(cmd, drvstr); VIR_FREE(drvstr); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 360d8cf..23a0fa5 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -140,7 +140,8 @@ char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps); char * qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, - virQEMUCapsPtr qemuCaps); + virQEMUCapsPtr qemuCaps, + const char *sysfs_root); char * qemuBuildSCSIHostdevDevStr(virDomainDefPtr def, virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps); diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index d5f94d5..44657d3 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -251,7 +251,8 @@ qemuUpdateActiveScsiHostdevs(virQEMUDriverPtr driver, hostdev->source.subsys.u.scsi.bus, hostdev->source.subsys.u.scsi.target, hostdev->source.subsys.u.scsi.unit, - hostdev->readonly))) + hostdev->readonly, + NULL))) goto cleanup; virSCSIDeviceSetUsedBy(scsi, def->name); @@ -906,7 +907,8 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver, hostdev->source.subsys.u.scsi.bus, hostdev->source.subsys.u.scsi.target, hostdev->source.subsys.u.scsi.unit, - hostdev->readonly))) + hostdev->readonly, + NULL))) goto cleanup; if (scsi && virSCSIDeviceListAdd(list, scsi) < 0) { @@ -1194,7 +1196,8 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver, hostdev->source.subsys.u.scsi.bus, hostdev->source.subsys.u.scsi.target, hostdev->source.subsys.u.scsi.unit, - hostdev->readonly))) { + hostdev->readonly, + NULL))) { VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s", hostdev->source.subsys.u.scsi.adapter, hostdev->source.subsys.u.scsi.bus, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d037c9d..85d6ccb 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1226,7 +1226,7 @@ qemuDomainAttachHostScsiDevice(virQEMUDriverPtr driver, if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, 0) < 0) goto cleanup; - if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps))) + if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps, NULL))) goto cleanup; if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qemuCaps))) @@ -2543,7 +2543,7 @@ qemuDomainDetachHostScsiDevice(virQEMUDriverPtr driver, return -1; } - if (!(drvstr = qemuBuildSCSIHostdevDrvStr(detach, priv->qemuCaps))) + if (!(drvstr = qemuBuildSCSIHostdevDrvStr(detach, priv->qemuCaps, NULL))) goto cleanup; if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, detach, priv->qemuCaps))) goto cleanup; diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 6e6fcad..e896a1c 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -550,7 +550,8 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL); if (!scsi) goto done; @@ -667,7 +668,8 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL); if (!scsi) goto done; diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 5d108b9..298a66f 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1370,7 +1370,8 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL); if (!scsi) goto done; @@ -1569,7 +1570,8 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL); if (!scsi) goto done; diff --git a/src/util/virscsi.c b/src/util/virscsi.c index d6685fa..dca9a8d 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -100,26 +100,50 @@ virSCSIDeviceGetAdapterId(const char *adapter, return 0; } +static char * +virSCSIDeviceSysfsRoot(const char *sysfs_root) +{ + char *ret = NULL; + + if (sysfs_root) { + if (virAsprintf(&ret, "%s/bus/scsi/devices", sysfs_root) < 0) { + virReportOOMError(); + return NULL; + } + } else { + if (VIR_STRDUP(ret, SYSFS_SCSI_DEVICES) < 0) + return NULL; + } + + return ret; +} + char * virSCSIDeviceGetSgName(const char *adapter, unsigned int bus, unsigned int target, - unsigned int unit) + unsigned int unit, + const char *sysfs_root) { DIR *dir = NULL; struct dirent *entry; char *path = NULL; char *sg = NULL; unsigned int adapter_id; + char *sysfs_prefix = NULL; if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0) return NULL; + if (!(sysfs_prefix = virSCSIDeviceSysfsRoot(sysfs_root))) + return NULL; + if (virAsprintf(&path, - SYSFS_SCSI_DEVICES "/%d:%d:%d:%d/scsi_generic", + "%s/%d:%d:%d:%d/scsi_generic", + sysfs_prefix, adapter_id, bus, target, unit) < 0) { virReportOOMError(); - return NULL; + goto cleanup; } if (!(dir = opendir(path))) { @@ -138,6 +162,7 @@ virSCSIDeviceGetSgName(const char *adapter, cleanup: closedir(dir); + VIR_FREE(sysfs_prefix); VIR_FREE(path); return sg; } @@ -147,7 +172,8 @@ virSCSIDeviceNew(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit, - bool readonly) + bool readonly, + const char *sysfs_root) { virSCSIDevicePtr dev, ret = NULL; char *sg = NULL; @@ -155,6 +181,7 @@ virSCSIDeviceNew(const char *adapter, char *model_path = NULL; char *vendor = NULL; char *model = NULL; + char *sysfs_prefix = NULL; if (VIR_ALLOC(dev) < 0) { virReportOOMError(); @@ -166,7 +193,7 @@ virSCSIDeviceNew(const char *adapter, dev->unit = unit; dev->readonly = readonly; - if (!(sg = virSCSIDeviceGetSgName(adapter, bus, target, unit))) + if (!(sg = virSCSIDeviceGetSgName(adapter, bus, target, unit, sysfs_root))) goto cleanup; if (virSCSIDeviceGetAdapterId(adapter, &dev->adapter) < 0) @@ -186,10 +213,15 @@ virSCSIDeviceNew(const char *adapter, goto cleanup; } - if (virAsprintf(&vendor_path, - SYSFS_SCSI_DEVICES "/%s/vendor", dev->name) < 0 || - virAsprintf(&model_path, - SYSFS_SCSI_DEVICES "/%s/model", dev->name) < 0) { + if (!(sysfs_prefix = virSCSIDeviceSysfsRoot(sysfs_root))) + goto cleanup; + + if (virAsprintf(&vendor_path, "%s/%s/vendor", + sysfs_prefix, + dev->name) < 0 || + virAsprintf(&model_path, "%s/%s/model", + sysfs_prefix, + dev->name) < 0) { virReportOOMError(); goto cleanup; } @@ -210,6 +242,7 @@ virSCSIDeviceNew(const char *adapter, ret = dev; cleanup: + VIR_FREE(sysfs_prefix); VIR_FREE(sg); VIR_FREE(vendor); VIR_FREE(model); diff --git a/src/util/virscsi.h b/src/util/virscsi.h index 8268cdf..4e51d5e 100644 --- a/src/util/virscsi.h +++ b/src/util/virscsi.h @@ -36,13 +36,15 @@ typedef virSCSIDeviceList *virSCSIDeviceListPtr; char *virSCSIDeviceGetSgName(const char *adapter, unsigned int bus, unsigned int target, - unsigned int unit); + unsigned int unit, + const char *sysfs_prefix); virSCSIDevicePtr virSCSIDeviceNew(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit, - bool readonly); + bool readonly, + const char *sysfs_prefix); void virSCSIDeviceFree(virSCSIDevicePtr dev); void virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev, const char *name); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 790857a..a975410 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -82,6 +82,8 @@ typedef enum { FLAG_JSON = 1 << 3, } virQemuXML2ArgvTestFlags; +# define SYSFS_ROOT "./sysfsroot" + static int testCompareXMLToArgvFiles(const char *xml, const char *cmdline, virQEMUCapsPtr extraFlags, @@ -158,7 +160,7 @@ static int testCompareXMLToArgvFiles(const char *xml, (flags & FLAG_JSON), extraFlags, migrateFrom, migrateFd, NULL, VIR_NETDEV_VPORT_PROFILE_OP_NO_OP, - NULL))) { + SYSFS_ROOT))) { if (flags & FLAG_EXPECT_FAILURE) { ret = 0; if (virTestGetDebug() > 1) diff --git a/tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev b/tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev new file mode 100644 index 0000000..992e920 --- /dev/null +++ b/tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev @@ -0,0 +1 @@ +21:0 -- 1.8.1.4

On Wed, May 15, 2013 at 06:52:45PM +0800, Osier Yang wrote:
This creates a new directory "sysfsroot" under "tests", any sysfs test input files should be put into it in future. Currently only the scsi-generic tests need to use it, so only one file path is created (bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev). --- src/qemu/qemu_cgroup.c | 3 +- src/qemu/qemu_command.c | 11 +++-- src/qemu/qemu_command.h | 3 +- src/qemu/qemu_hostdev.c | 9 ++-- src/qemu/qemu_hotplug.c | 4 +- src/security/security_dac.c | 6 ++- src/security/security_selinux.c | 6 ++- src/util/virscsi.c | 51 ++++++++++++++++++---- src/util/virscsi.h | 6 ++- tests/qemuxml2argvtest.c | 4 +- .../bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev | 1 + 11 files changed, 77 insertions(+), 27 deletions(-) create mode 100644 tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index aaf94cf..55593e2 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -321,7 +321,8 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly)) == NULL) + dev->readonly, + NULL)) == NULL) goto cleanup;
if (virSCSIDeviceFileIterate(scsi, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e054c1f..9f49a7d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4746,7 +4746,8 @@ qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev)
char * qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, - virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED) + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, + const char *sysfs_root) { virBuffer buf = VIR_BUFFER_INITIALIZER; char *sg = NULL; @@ -4754,7 +4755,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, if (!(sg = virSCSIDeviceGetSgName(dev->source.subsys.u.scsi.adapter, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, - dev->source.subsys.u.scsi.unit))) { + dev->source.subsys.u.scsi.unit, + sysfs_root))) { goto error; }
@@ -6401,7 +6403,7 @@ qemuBuildCommandLine(virConnectPtr conn, int migrateFd, virDomainSnapshotObjPtr snapshot, enum virNetDevVPortProfileOp vmop, - const char *sysfs_root ATTRIBUTE_UNUSED) + const char *sysfs_root) { virErrorPtr originalError = NULL; int i, j; @@ -8213,7 +8215,8 @@ qemuBuildCommandLine(virConnectPtr conn, char *drvstr;
virCommandAddArg(cmd, "-drive"); - if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps))) + if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps, + sysfs_root))) goto error; virCommandAddArg(cmd, drvstr); VIR_FREE(drvstr); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 360d8cf..23a0fa5 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -140,7 +140,8 @@ char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps);
char * qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, - virQEMUCapsPtr qemuCaps); + virQEMUCapsPtr qemuCaps, + const char *sysfs_root); char * qemuBuildSCSIHostdevDevStr(virDomainDefPtr def, virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps); diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index d5f94d5..44657d3 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -251,7 +251,8 @@ qemuUpdateActiveScsiHostdevs(virQEMUDriverPtr driver, hostdev->source.subsys.u.scsi.bus, hostdev->source.subsys.u.scsi.target, hostdev->source.subsys.u.scsi.unit, - hostdev->readonly))) + hostdev->readonly, + NULL))) goto cleanup;
virSCSIDeviceSetUsedBy(scsi, def->name); @@ -906,7 +907,8 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver, hostdev->source.subsys.u.scsi.bus, hostdev->source.subsys.u.scsi.target, hostdev->source.subsys.u.scsi.unit, - hostdev->readonly))) + hostdev->readonly, + NULL))) goto cleanup;
if (scsi && virSCSIDeviceListAdd(list, scsi) < 0) { @@ -1194,7 +1196,8 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver, hostdev->source.subsys.u.scsi.bus, hostdev->source.subsys.u.scsi.target, hostdev->source.subsys.u.scsi.unit, - hostdev->readonly))) { + hostdev->readonly, + NULL))) { VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s", hostdev->source.subsys.u.scsi.adapter, hostdev->source.subsys.u.scsi.bus, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d037c9d..85d6ccb 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1226,7 +1226,7 @@ qemuDomainAttachHostScsiDevice(virQEMUDriverPtr driver, if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, 0) < 0) goto cleanup;
- if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps))) + if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps, NULL))) goto cleanup;
if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qemuCaps))) @@ -2543,7 +2543,7 @@ qemuDomainDetachHostScsiDevice(virQEMUDriverPtr driver, return -1; }
- if (!(drvstr = qemuBuildSCSIHostdevDrvStr(detach, priv->qemuCaps))) + if (!(drvstr = qemuBuildSCSIHostdevDrvStr(detach, priv->qemuCaps, NULL))) goto cleanup; if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, detach, priv->qemuCaps))) goto cleanup; diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 6e6fcad..e896a1c 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -550,7 +550,8 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL);
if (!scsi) goto done; @@ -667,7 +668,8 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL);
if (!scsi) goto done; diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 5d108b9..298a66f 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1370,7 +1370,8 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL);
if (!scsi) goto done; @@ -1569,7 +1570,8 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr, dev->source.subsys.u.scsi.bus, dev->source.subsys.u.scsi.target, dev->source.subsys.u.scsi.unit, - dev->readonly); + dev->readonly, + NULL);
if (!scsi) goto done; diff --git a/src/util/virscsi.c b/src/util/virscsi.c index d6685fa..dca9a8d 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -100,26 +100,50 @@ virSCSIDeviceGetAdapterId(const char *adapter, return 0; }
+static char * +virSCSIDeviceSysfsRoot(const char *sysfs_root) +{ + char *ret = NULL; + + if (sysfs_root) { + if (virAsprintf(&ret, "%s/bus/scsi/devices", sysfs_root) < 0) { + virReportOOMError(); + return NULL; + } + } else { + if (VIR_STRDUP(ret, SYSFS_SCSI_DEVICES) < 0) + return NULL; + } + + return ret; +} + char * virSCSIDeviceGetSgName(const char *adapter, unsigned int bus, unsigned int target, - unsigned int unit) + unsigned int unit, + const char *sysfs_root) { DIR *dir = NULL; struct dirent *entry; char *path = NULL; char *sg = NULL; unsigned int adapter_id; + char *sysfs_prefix = NULL;
if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0) return NULL;
+ if (!(sysfs_prefix = virSCSIDeviceSysfsRoot(sysfs_root))) + return NULL; + if (virAsprintf(&path, - SYSFS_SCSI_DEVICES "/%d:%d:%d:%d/scsi_generic", + "%s/%d:%d:%d:%d/scsi_generic", + sysfs_prefix, adapter_id, bus, target, unit) < 0) { virReportOOMError(); - return NULL; + goto cleanup; }
if (!(dir = opendir(path))) { @@ -138,6 +162,7 @@ virSCSIDeviceGetSgName(const char *adapter,
cleanup: closedir(dir); + VIR_FREE(sysfs_prefix); VIR_FREE(path); return sg; } @@ -147,7 +172,8 @@ virSCSIDeviceNew(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit, - bool readonly) + bool readonly, + const char *sysfs_root) { virSCSIDevicePtr dev, ret = NULL; char *sg = NULL; @@ -155,6 +181,7 @@ virSCSIDeviceNew(const char *adapter, char *model_path = NULL; char *vendor = NULL; char *model = NULL; + char *sysfs_prefix = NULL;
if (VIR_ALLOC(dev) < 0) { virReportOOMError(); @@ -166,7 +193,7 @@ virSCSIDeviceNew(const char *adapter, dev->unit = unit; dev->readonly = readonly;
- if (!(sg = virSCSIDeviceGetSgName(adapter, bus, target, unit))) + if (!(sg = virSCSIDeviceGetSgName(adapter, bus, target, unit, sysfs_root))) goto cleanup;
if (virSCSIDeviceGetAdapterId(adapter, &dev->adapter) < 0) @@ -186,10 +213,15 @@ virSCSIDeviceNew(const char *adapter, goto cleanup; }
- if (virAsprintf(&vendor_path, - SYSFS_SCSI_DEVICES "/%s/vendor", dev->name) < 0 || - virAsprintf(&model_path, - SYSFS_SCSI_DEVICES "/%s/model", dev->name) < 0) { + if (!(sysfs_prefix = virSCSIDeviceSysfsRoot(sysfs_root))) + goto cleanup; + + if (virAsprintf(&vendor_path, "%s/%s/vendor", + sysfs_prefix, + dev->name) < 0 || + virAsprintf(&model_path, "%s/%s/model", + sysfs_prefix, + dev->name) < 0) { virReportOOMError(); goto cleanup; } @@ -210,6 +242,7 @@ virSCSIDeviceNew(const char *adapter,
ret = dev; cleanup: + VIR_FREE(sysfs_prefix); VIR_FREE(sg); VIR_FREE(vendor); VIR_FREE(model); diff --git a/src/util/virscsi.h b/src/util/virscsi.h index 8268cdf..4e51d5e 100644 --- a/src/util/virscsi.h +++ b/src/util/virscsi.h @@ -36,13 +36,15 @@ typedef virSCSIDeviceList *virSCSIDeviceListPtr; char *virSCSIDeviceGetSgName(const char *adapter, unsigned int bus, unsigned int target, - unsigned int unit); + unsigned int unit, + const char *sysfs_prefix);
virSCSIDevicePtr virSCSIDeviceNew(const char *adapter, unsigned int bus, unsigned int target, unsigned int unit, - bool readonly); + bool readonly, + const char *sysfs_prefix);
void virSCSIDeviceFree(virSCSIDevicePtr dev); void virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev, const char *name); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 790857a..a975410 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -82,6 +82,8 @@ typedef enum { FLAG_JSON = 1 << 3, } virQemuXML2ArgvTestFlags;
+# define SYSFS_ROOT "./sysfsroot" + static int testCompareXMLToArgvFiles(const char *xml, const char *cmdline, virQEMUCapsPtr extraFlags, @@ -158,7 +160,7 @@ static int testCompareXMLToArgvFiles(const char *xml, (flags & FLAG_JSON), extraFlags, migrateFrom, migrateFd, NULL, VIR_NETDEV_VPORT_PROFILE_OP_NO_OP, - NULL))) { + SYSFS_ROOT))) { if (flags & FLAG_EXPECT_FAILURE) { ret = 0; if (virTestGetDebug() > 1) diff --git a/tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev b/tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev new file mode 100644 index 0000000..992e920 --- /dev/null +++ b/tests/sysfsroot/bus/scsi/devices/0:0:0:0/scsi_generic/sg0/dev @@ -0,0 +1 @@ +21:0
ACK
-- 1.8.1.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

"fchostdata" is also about sysfs files, it can go home now. --- tests/Makefile.am | 2 +- tests/fchostdata/fc_host/host4/fabric_name | 1 - tests/fchostdata/fc_host/host4/max_npiv_vports | 1 - tests/fchostdata/fc_host/host4/node_name | 1 - tests/fchostdata/fc_host/host4/npiv_vports_inuse | 1 - tests/fchostdata/fc_host/host4/port_name | 1 - tests/fchostdata/fc_host/host4/port_state | 1 - tests/fchostdata/fc_host/host4/vport_create | 0 tests/fchostdata/fc_host/host4/vport_delete | 0 tests/fchostdata/fc_host/host5/fabric_name | 1 - tests/fchostdata/fc_host/host5/max_npiv_vports | 1 - tests/fchostdata/fc_host/host5/node_name | 1 - tests/fchostdata/fc_host/host5/npiv_vports_inuse | 1 - tests/fchostdata/fc_host/host5/port_name | 1 - tests/fchostdata/fc_host/host5/port_state | 1 - tests/fchostdata/fc_host/host5/vport_create | 0 tests/fchostdata/fc_host/host5/vport_delete | 0 tests/fchosttest.c | 2 +- tests/sysfsroot/class/fc_host/host4/fabric_name | 1 + tests/sysfsroot/class/fc_host/host4/max_npiv_vports | 1 + tests/sysfsroot/class/fc_host/host4/node_name | 1 + tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse | 1 + tests/sysfsroot/class/fc_host/host4/port_name | 1 + tests/sysfsroot/class/fc_host/host4/port_state | 1 + tests/sysfsroot/class/fc_host/host4/vport_create | 0 tests/sysfsroot/class/fc_host/host4/vport_delete | 0 tests/sysfsroot/class/fc_host/host5/fabric_name | 1 + tests/sysfsroot/class/fc_host/host5/max_npiv_vports | 1 + tests/sysfsroot/class/fc_host/host5/node_name | 1 + tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse | 1 + tests/sysfsroot/class/fc_host/host5/port_name | 1 + tests/sysfsroot/class/fc_host/host5/port_state | 1 + tests/sysfsroot/class/fc_host/host5/vport_create | 0 tests/sysfsroot/class/fc_host/host5/vport_delete | 0 34 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 tests/fchostdata/fc_host/host4/fabric_name delete mode 100644 tests/fchostdata/fc_host/host4/max_npiv_vports delete mode 100644 tests/fchostdata/fc_host/host4/node_name delete mode 100644 tests/fchostdata/fc_host/host4/npiv_vports_inuse delete mode 100644 tests/fchostdata/fc_host/host4/port_name delete mode 100644 tests/fchostdata/fc_host/host4/port_state delete mode 100644 tests/fchostdata/fc_host/host4/vport_create delete mode 100644 tests/fchostdata/fc_host/host4/vport_delete delete mode 100644 tests/fchostdata/fc_host/host5/fabric_name delete mode 100644 tests/fchostdata/fc_host/host5/max_npiv_vports delete mode 100644 tests/fchostdata/fc_host/host5/node_name delete mode 100644 tests/fchostdata/fc_host/host5/npiv_vports_inuse delete mode 100644 tests/fchostdata/fc_host/host5/port_name delete mode 100644 tests/fchostdata/fc_host/host5/port_state delete mode 100644 tests/fchostdata/fc_host/host5/vport_create delete mode 100644 tests/fchostdata/fc_host/host5/vport_delete create mode 100644 tests/sysfsroot/class/fc_host/host4/fabric_name create mode 100644 tests/sysfsroot/class/fc_host/host4/max_npiv_vports create mode 100644 tests/sysfsroot/class/fc_host/host4/node_name create mode 100644 tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse create mode 100644 tests/sysfsroot/class/fc_host/host4/port_name create mode 100644 tests/sysfsroot/class/fc_host/host4/port_state create mode 100644 tests/sysfsroot/class/fc_host/host4/vport_create create mode 100644 tests/sysfsroot/class/fc_host/host4/vport_delete create mode 100644 tests/sysfsroot/class/fc_host/host5/fabric_name create mode 100644 tests/sysfsroot/class/fc_host/host5/max_npiv_vports create mode 100644 tests/sysfsroot/class/fc_host/host5/node_name create mode 100644 tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse create mode 100644 tests/sysfsroot/class/fc_host/host5/port_name create mode 100644 tests/sysfsroot/class/fc_host/host5/port_state create mode 100644 tests/sysfsroot/class/fc_host/host5/vport_create create mode 100644 tests/sysfsroot/class/fc_host/host5/vport_delete diff --git a/tests/Makefile.am b/tests/Makefile.am index 41c4067..3ae9015 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,7 +52,6 @@ EXTRA_DIST = \ domainsnapshotschematest \ domainsnapshotxml2xmlin \ domainsnapshotxml2xmlout \ - fchostdata \ interfaceschemadata \ lxcxml2xmldata \ networkschematest \ @@ -80,6 +79,7 @@ EXTRA_DIST = \ storagevolschematest \ storagevolxml2xmlin \ storagevolxml2xmlout \ + sysfsroot \ sysinfodata \ test-lib.sh \ vmx2xmldata \ diff --git a/tests/fchostdata/fc_host/host4/fabric_name b/tests/fchostdata/fc_host/host4/fabric_name deleted file mode 100644 index f587b68..0000000 --- a/tests/fchostdata/fc_host/host4/fabric_name +++ /dev/null @@ -1 +0,0 @@ -0xffffffffffffffff diff --git a/tests/fchostdata/fc_host/host4/max_npiv_vports b/tests/fchostdata/fc_host/host4/max_npiv_vports deleted file mode 100644 index c75acbe..0000000 --- a/tests/fchostdata/fc_host/host4/max_npiv_vports +++ /dev/null @@ -1 +0,0 @@ -127 diff --git a/tests/fchostdata/fc_host/host4/node_name b/tests/fchostdata/fc_host/host4/node_name deleted file mode 100644 index e8c1e1a..0000000 --- a/tests/fchostdata/fc_host/host4/node_name +++ /dev/null @@ -1 +0,0 @@ -0x2000001b3289da4e diff --git a/tests/fchostdata/fc_host/host4/npiv_vports_inuse b/tests/fchostdata/fc_host/host4/npiv_vports_inuse deleted file mode 100644 index 573541a..0000000 --- a/tests/fchostdata/fc_host/host4/npiv_vports_inuse +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/fchostdata/fc_host/host4/port_name b/tests/fchostdata/fc_host/host4/port_name deleted file mode 100644 index ee2d399..0000000 --- a/tests/fchostdata/fc_host/host4/port_name +++ /dev/null @@ -1 +0,0 @@ -0x2100001b3289da4e diff --git a/tests/fchostdata/fc_host/host4/port_state b/tests/fchostdata/fc_host/host4/port_state deleted file mode 100644 index bd1e6d5..0000000 --- a/tests/fchostdata/fc_host/host4/port_state +++ /dev/null @@ -1 +0,0 @@ -Linkdown diff --git a/tests/fchostdata/fc_host/host4/vport_create b/tests/fchostdata/fc_host/host4/vport_create deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchostdata/fc_host/host4/vport_delete b/tests/fchostdata/fc_host/host4/vport_delete deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchostdata/fc_host/host5/fabric_name b/tests/fchostdata/fc_host/host5/fabric_name deleted file mode 100644 index 4128070..0000000 --- a/tests/fchostdata/fc_host/host5/fabric_name +++ /dev/null @@ -1 +0,0 @@ -0x2001000dec9877c1 diff --git a/tests/fchostdata/fc_host/host5/max_npiv_vports b/tests/fchostdata/fc_host/host5/max_npiv_vports deleted file mode 100644 index c75acbe..0000000 --- a/tests/fchostdata/fc_host/host5/max_npiv_vports +++ /dev/null @@ -1 +0,0 @@ -127 diff --git a/tests/fchostdata/fc_host/host5/node_name b/tests/fchostdata/fc_host/host5/node_name deleted file mode 100644 index 91a0a05..0000000 --- a/tests/fchostdata/fc_host/host5/node_name +++ /dev/null @@ -1 +0,0 @@ -0x2001001b32a9da4e diff --git a/tests/fchostdata/fc_host/host5/npiv_vports_inuse b/tests/fchostdata/fc_host/host5/npiv_vports_inuse deleted file mode 100644 index 573541a..0000000 --- a/tests/fchostdata/fc_host/host5/npiv_vports_inuse +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/fchostdata/fc_host/host5/port_name b/tests/fchostdata/fc_host/host5/port_name deleted file mode 100644 index c37f618..0000000 --- a/tests/fchostdata/fc_host/host5/port_name +++ /dev/null @@ -1 +0,0 @@ -0x2101001b32a9da4e diff --git a/tests/fchostdata/fc_host/host5/port_state b/tests/fchostdata/fc_host/host5/port_state deleted file mode 100644 index b73dd46..0000000 --- a/tests/fchostdata/fc_host/host5/port_state +++ /dev/null @@ -1 +0,0 @@ -Online diff --git a/tests/fchostdata/fc_host/host5/vport_create b/tests/fchostdata/fc_host/host5/vport_create deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchostdata/fc_host/host5/vport_delete b/tests/fchostdata/fc_host/host5/vport_delete deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchosttest.c b/tests/fchosttest.c index 035f721..3d64671 100644 --- a/tests/fchosttest.c +++ b/tests/fchosttest.c @@ -22,7 +22,7 @@ #include "virutil.h" #include "testutils.h" -#define TEST_FC_HOST_PREFIX "./fchostdata/fc_host/" +#define TEST_FC_HOST_PREFIX "./sysfsroot/class/fc_host/" #define TEST_FC_HOST_NUM 5 /* Test virIsCapableFCHost */ diff --git a/tests/sysfsroot/class/fc_host/host4/fabric_name b/tests/sysfsroot/class/fc_host/host4/fabric_name new file mode 100644 index 0000000..f587b68 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/fabric_name @@ -0,0 +1 @@ +0xffffffffffffffff diff --git a/tests/sysfsroot/class/fc_host/host4/max_npiv_vports b/tests/sysfsroot/class/fc_host/host4/max_npiv_vports new file mode 100644 index 0000000..c75acbe --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/max_npiv_vports @@ -0,0 +1 @@ +127 diff --git a/tests/sysfsroot/class/fc_host/host4/node_name b/tests/sysfsroot/class/fc_host/host4/node_name new file mode 100644 index 0000000..e8c1e1a --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/node_name @@ -0,0 +1 @@ +0x2000001b3289da4e diff --git a/tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse b/tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse @@ -0,0 +1 @@ +0 diff --git a/tests/sysfsroot/class/fc_host/host4/port_name b/tests/sysfsroot/class/fc_host/host4/port_name new file mode 100644 index 0000000..ee2d399 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/port_name @@ -0,0 +1 @@ +0x2100001b3289da4e diff --git a/tests/sysfsroot/class/fc_host/host4/port_state b/tests/sysfsroot/class/fc_host/host4/port_state new file mode 100644 index 0000000..bd1e6d5 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/port_state @@ -0,0 +1 @@ +Linkdown diff --git a/tests/sysfsroot/class/fc_host/host4/vport_create b/tests/sysfsroot/class/fc_host/host4/vport_create new file mode 100644 index 0000000..e69de29 diff --git a/tests/sysfsroot/class/fc_host/host4/vport_delete b/tests/sysfsroot/class/fc_host/host4/vport_delete new file mode 100644 index 0000000..e69de29 diff --git a/tests/sysfsroot/class/fc_host/host5/fabric_name b/tests/sysfsroot/class/fc_host/host5/fabric_name new file mode 100644 index 0000000..4128070 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/fabric_name @@ -0,0 +1 @@ +0x2001000dec9877c1 diff --git a/tests/sysfsroot/class/fc_host/host5/max_npiv_vports b/tests/sysfsroot/class/fc_host/host5/max_npiv_vports new file mode 100644 index 0000000..c75acbe --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/max_npiv_vports @@ -0,0 +1 @@ +127 diff --git a/tests/sysfsroot/class/fc_host/host5/node_name b/tests/sysfsroot/class/fc_host/host5/node_name new file mode 100644 index 0000000..91a0a05 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/node_name @@ -0,0 +1 @@ +0x2001001b32a9da4e diff --git a/tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse b/tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse @@ -0,0 +1 @@ +0 diff --git a/tests/sysfsroot/class/fc_host/host5/port_name b/tests/sysfsroot/class/fc_host/host5/port_name new file mode 100644 index 0000000..c37f618 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/port_name @@ -0,0 +1 @@ +0x2101001b32a9da4e diff --git a/tests/sysfsroot/class/fc_host/host5/port_state b/tests/sysfsroot/class/fc_host/host5/port_state new file mode 100644 index 0000000..b73dd46 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/port_state @@ -0,0 +1 @@ +Online diff --git a/tests/sysfsroot/class/fc_host/host5/vport_create b/tests/sysfsroot/class/fc_host/host5/vport_create new file mode 100644 index 0000000..e69de29 diff --git a/tests/sysfsroot/class/fc_host/host5/vport_delete b/tests/sysfsroot/class/fc_host/host5/vport_delete new file mode 100644 index 0000000..e69de29 -- 1.8.1.4

On Wed, May 15, 2013 at 06:52:46PM +0800, Osier Yang wrote:
"fchostdata" is also about sysfs files, it can go home now. --- tests/Makefile.am | 2 +- tests/fchostdata/fc_host/host4/fabric_name | 1 - tests/fchostdata/fc_host/host4/max_npiv_vports | 1 - tests/fchostdata/fc_host/host4/node_name | 1 - tests/fchostdata/fc_host/host4/npiv_vports_inuse | 1 - tests/fchostdata/fc_host/host4/port_name | 1 - tests/fchostdata/fc_host/host4/port_state | 1 - tests/fchostdata/fc_host/host4/vport_create | 0 tests/fchostdata/fc_host/host4/vport_delete | 0 tests/fchostdata/fc_host/host5/fabric_name | 1 - tests/fchostdata/fc_host/host5/max_npiv_vports | 1 - tests/fchostdata/fc_host/host5/node_name | 1 - tests/fchostdata/fc_host/host5/npiv_vports_inuse | 1 - tests/fchostdata/fc_host/host5/port_name | 1 - tests/fchostdata/fc_host/host5/port_state | 1 - tests/fchostdata/fc_host/host5/vport_create | 0 tests/fchostdata/fc_host/host5/vport_delete | 0 tests/fchosttest.c | 2 +- tests/sysfsroot/class/fc_host/host4/fabric_name | 1 + tests/sysfsroot/class/fc_host/host4/max_npiv_vports | 1 + tests/sysfsroot/class/fc_host/host4/node_name | 1 + tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse | 1 + tests/sysfsroot/class/fc_host/host4/port_name | 1 + tests/sysfsroot/class/fc_host/host4/port_state | 1 + tests/sysfsroot/class/fc_host/host4/vport_create | 0 tests/sysfsroot/class/fc_host/host4/vport_delete | 0 tests/sysfsroot/class/fc_host/host5/fabric_name | 1 + tests/sysfsroot/class/fc_host/host5/max_npiv_vports | 1 + tests/sysfsroot/class/fc_host/host5/node_name | 1 + tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse | 1 + tests/sysfsroot/class/fc_host/host5/port_name | 1 + tests/sysfsroot/class/fc_host/host5/port_state | 1 + tests/sysfsroot/class/fc_host/host5/vport_create | 0 tests/sysfsroot/class/fc_host/host5/vport_delete | 0 34 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 tests/fchostdata/fc_host/host4/fabric_name delete mode 100644 tests/fchostdata/fc_host/host4/max_npiv_vports delete mode 100644 tests/fchostdata/fc_host/host4/node_name delete mode 100644 tests/fchostdata/fc_host/host4/npiv_vports_inuse delete mode 100644 tests/fchostdata/fc_host/host4/port_name delete mode 100644 tests/fchostdata/fc_host/host4/port_state delete mode 100644 tests/fchostdata/fc_host/host4/vport_create delete mode 100644 tests/fchostdata/fc_host/host4/vport_delete delete mode 100644 tests/fchostdata/fc_host/host5/fabric_name delete mode 100644 tests/fchostdata/fc_host/host5/max_npiv_vports delete mode 100644 tests/fchostdata/fc_host/host5/node_name delete mode 100644 tests/fchostdata/fc_host/host5/npiv_vports_inuse delete mode 100644 tests/fchostdata/fc_host/host5/port_name delete mode 100644 tests/fchostdata/fc_host/host5/port_state delete mode 100644 tests/fchostdata/fc_host/host5/vport_create delete mode 100644 tests/fchostdata/fc_host/host5/vport_delete create mode 100644 tests/sysfsroot/class/fc_host/host4/fabric_name create mode 100644 tests/sysfsroot/class/fc_host/host4/max_npiv_vports create mode 100644 tests/sysfsroot/class/fc_host/host4/node_name create mode 100644 tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse create mode 100644 tests/sysfsroot/class/fc_host/host4/port_name create mode 100644 tests/sysfsroot/class/fc_host/host4/port_state create mode 100644 tests/sysfsroot/class/fc_host/host4/vport_create create mode 100644 tests/sysfsroot/class/fc_host/host4/vport_delete create mode 100644 tests/sysfsroot/class/fc_host/host5/fabric_name create mode 100644 tests/sysfsroot/class/fc_host/host5/max_npiv_vports create mode 100644 tests/sysfsroot/class/fc_host/host5/node_name create mode 100644 tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse create mode 100644 tests/sysfsroot/class/fc_host/host5/port_name create mode 100644 tests/sysfsroot/class/fc_host/host5/port_state create mode 100644 tests/sysfsroot/class/fc_host/host5/vport_create create mode 100644 tests/sysfsroot/class/fc_host/host5/vport_delete
diff --git a/tests/Makefile.am b/tests/Makefile.am index 41c4067..3ae9015 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,7 +52,6 @@ EXTRA_DIST = \ domainsnapshotschematest \ domainsnapshotxml2xmlin \ domainsnapshotxml2xmlout \ - fchostdata \ interfaceschemadata \ lxcxml2xmldata \ networkschematest \ @@ -80,6 +79,7 @@ EXTRA_DIST = \ storagevolschematest \ storagevolxml2xmlin \ storagevolxml2xmlout \ + sysfsroot \ sysinfodata \ test-lib.sh \ vmx2xmldata \ diff --git a/tests/fchostdata/fc_host/host4/fabric_name b/tests/fchostdata/fc_host/host4/fabric_name deleted file mode 100644 index f587b68..0000000 --- a/tests/fchostdata/fc_host/host4/fabric_name +++ /dev/null @@ -1 +0,0 @@ -0xffffffffffffffff diff --git a/tests/fchostdata/fc_host/host4/max_npiv_vports b/tests/fchostdata/fc_host/host4/max_npiv_vports deleted file mode 100644 index c75acbe..0000000 --- a/tests/fchostdata/fc_host/host4/max_npiv_vports +++ /dev/null @@ -1 +0,0 @@ -127 diff --git a/tests/fchostdata/fc_host/host4/node_name b/tests/fchostdata/fc_host/host4/node_name deleted file mode 100644 index e8c1e1a..0000000 --- a/tests/fchostdata/fc_host/host4/node_name +++ /dev/null @@ -1 +0,0 @@ -0x2000001b3289da4e diff --git a/tests/fchostdata/fc_host/host4/npiv_vports_inuse b/tests/fchostdata/fc_host/host4/npiv_vports_inuse deleted file mode 100644 index 573541a..0000000 --- a/tests/fchostdata/fc_host/host4/npiv_vports_inuse +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/fchostdata/fc_host/host4/port_name b/tests/fchostdata/fc_host/host4/port_name deleted file mode 100644 index ee2d399..0000000 --- a/tests/fchostdata/fc_host/host4/port_name +++ /dev/null @@ -1 +0,0 @@ -0x2100001b3289da4e diff --git a/tests/fchostdata/fc_host/host4/port_state b/tests/fchostdata/fc_host/host4/port_state deleted file mode 100644 index bd1e6d5..0000000 --- a/tests/fchostdata/fc_host/host4/port_state +++ /dev/null @@ -1 +0,0 @@ -Linkdown diff --git a/tests/fchostdata/fc_host/host4/vport_create b/tests/fchostdata/fc_host/host4/vport_create deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchostdata/fc_host/host4/vport_delete b/tests/fchostdata/fc_host/host4/vport_delete deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchostdata/fc_host/host5/fabric_name b/tests/fchostdata/fc_host/host5/fabric_name deleted file mode 100644 index 4128070..0000000 --- a/tests/fchostdata/fc_host/host5/fabric_name +++ /dev/null @@ -1 +0,0 @@ -0x2001000dec9877c1 diff --git a/tests/fchostdata/fc_host/host5/max_npiv_vports b/tests/fchostdata/fc_host/host5/max_npiv_vports deleted file mode 100644 index c75acbe..0000000 --- a/tests/fchostdata/fc_host/host5/max_npiv_vports +++ /dev/null @@ -1 +0,0 @@ -127 diff --git a/tests/fchostdata/fc_host/host5/node_name b/tests/fchostdata/fc_host/host5/node_name deleted file mode 100644 index 91a0a05..0000000 --- a/tests/fchostdata/fc_host/host5/node_name +++ /dev/null @@ -1 +0,0 @@ -0x2001001b32a9da4e diff --git a/tests/fchostdata/fc_host/host5/npiv_vports_inuse b/tests/fchostdata/fc_host/host5/npiv_vports_inuse deleted file mode 100644 index 573541a..0000000 --- a/tests/fchostdata/fc_host/host5/npiv_vports_inuse +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/fchostdata/fc_host/host5/port_name b/tests/fchostdata/fc_host/host5/port_name deleted file mode 100644 index c37f618..0000000 --- a/tests/fchostdata/fc_host/host5/port_name +++ /dev/null @@ -1 +0,0 @@ -0x2101001b32a9da4e diff --git a/tests/fchostdata/fc_host/host5/port_state b/tests/fchostdata/fc_host/host5/port_state deleted file mode 100644 index b73dd46..0000000 --- a/tests/fchostdata/fc_host/host5/port_state +++ /dev/null @@ -1 +0,0 @@ -Online diff --git a/tests/fchostdata/fc_host/host5/vport_create b/tests/fchostdata/fc_host/host5/vport_create deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchostdata/fc_host/host5/vport_delete b/tests/fchostdata/fc_host/host5/vport_delete deleted file mode 100644 index e69de29..0000000 diff --git a/tests/fchosttest.c b/tests/fchosttest.c index 035f721..3d64671 100644 --- a/tests/fchosttest.c +++ b/tests/fchosttest.c @@ -22,7 +22,7 @@ #include "virutil.h" #include "testutils.h"
-#define TEST_FC_HOST_PREFIX "./fchostdata/fc_host/" +#define TEST_FC_HOST_PREFIX "./sysfsroot/class/fc_host/" #define TEST_FC_HOST_NUM 5
/* Test virIsCapableFCHost */ diff --git a/tests/sysfsroot/class/fc_host/host4/fabric_name b/tests/sysfsroot/class/fc_host/host4/fabric_name new file mode 100644 index 0000000..f587b68 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/fabric_name @@ -0,0 +1 @@ +0xffffffffffffffff diff --git a/tests/sysfsroot/class/fc_host/host4/max_npiv_vports b/tests/sysfsroot/class/fc_host/host4/max_npiv_vports new file mode 100644 index 0000000..c75acbe --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/max_npiv_vports @@ -0,0 +1 @@ +127 diff --git a/tests/sysfsroot/class/fc_host/host4/node_name b/tests/sysfsroot/class/fc_host/host4/node_name new file mode 100644 index 0000000..e8c1e1a --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/node_name @@ -0,0 +1 @@ +0x2000001b3289da4e diff --git a/tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse b/tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/npiv_vports_inuse @@ -0,0 +1 @@ +0 diff --git a/tests/sysfsroot/class/fc_host/host4/port_name b/tests/sysfsroot/class/fc_host/host4/port_name new file mode 100644 index 0000000..ee2d399 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/port_name @@ -0,0 +1 @@ +0x2100001b3289da4e diff --git a/tests/sysfsroot/class/fc_host/host4/port_state b/tests/sysfsroot/class/fc_host/host4/port_state new file mode 100644 index 0000000..bd1e6d5 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host4/port_state @@ -0,0 +1 @@ +Linkdown diff --git a/tests/sysfsroot/class/fc_host/host4/vport_create b/tests/sysfsroot/class/fc_host/host4/vport_create new file mode 100644 index 0000000..e69de29 diff --git a/tests/sysfsroot/class/fc_host/host4/vport_delete b/tests/sysfsroot/class/fc_host/host4/vport_delete new file mode 100644 index 0000000..e69de29 diff --git a/tests/sysfsroot/class/fc_host/host5/fabric_name b/tests/sysfsroot/class/fc_host/host5/fabric_name new file mode 100644 index 0000000..4128070 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/fabric_name @@ -0,0 +1 @@ +0x2001000dec9877c1 diff --git a/tests/sysfsroot/class/fc_host/host5/max_npiv_vports b/tests/sysfsroot/class/fc_host/host5/max_npiv_vports new file mode 100644 index 0000000..c75acbe --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/max_npiv_vports @@ -0,0 +1 @@ +127 diff --git a/tests/sysfsroot/class/fc_host/host5/node_name b/tests/sysfsroot/class/fc_host/host5/node_name new file mode 100644 index 0000000..91a0a05 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/node_name @@ -0,0 +1 @@ +0x2001001b32a9da4e diff --git a/tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse b/tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/npiv_vports_inuse @@ -0,0 +1 @@ +0 diff --git a/tests/sysfsroot/class/fc_host/host5/port_name b/tests/sysfsroot/class/fc_host/host5/port_name new file mode 100644 index 0000000..c37f618 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/port_name @@ -0,0 +1 @@ +0x2101001b32a9da4e diff --git a/tests/sysfsroot/class/fc_host/host5/port_state b/tests/sysfsroot/class/fc_host/host5/port_state new file mode 100644 index 0000000..b73dd46 --- /dev/null +++ b/tests/sysfsroot/class/fc_host/host5/port_state @@ -0,0 +1 @@ +Online diff --git a/tests/sysfsroot/class/fc_host/host5/vport_create b/tests/sysfsroot/class/fc_host/host5/vport_create new file mode 100644 index 0000000..e69de29 diff --git a/tests/sysfsroot/class/fc_host/host5/vport_delete b/tests/sysfsroot/class/fc_host/host5/vport_delete new file mode 100644 index 0000000..e69de29
ACK.
-- 1.8.1.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (4)
-
Daniel P. Berrange
-
Guido Günther
-
Laine Stump
-
Osier Yang