[libvirt] a libvirt event question
by Chen, Xiaogang
Hello:
We are adding libvirt functions to launch SEV VM. When start VM I put it at "pause" state. During that time qemu sends an event "sev_measurement". We hope libvirtd get this event before we resume VM. But I did not see libvirtd receive it. If I send this event at qemu during resume time libvirtd can get this event successfully. I traced qemuMonitorJSONIOProcessEvent function for events received, did not see any event coming before resume VM.
Is there something I missed to get this event during pause state? Thank you for your help.
Regards
Xiaogang
6 years, 11 months
[libvirt] [PATCH v3] libvirtd: clarify the TLS conf default value setting
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
Provide more details related to the requirement that setting one
of the values requires setting all of them.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
v3:
description updated follow John's comments
v2:
fix a typo
daemon/libvirtd.conf | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
index 8e0c0d96d..91b3f47de 100644
--- a/daemon/libvirtd.conf
+++ b/daemon/libvirtd.conf
@@ -182,6 +182,20 @@
# TLS x509 certificate configuration
#
+# Use of TLS requires that x509 certificates be issued. The default locations
+# for the certificate files is as follows:
+#
+# /etc/pki/CA/cacert.pem - The CA master certificate
+# /etc/pki/libvirt/servercert.pem - The server certificate signed with
+# the cacert.pem
+# /etc/pki/libvirt/private/serverkey.pem - The server private key
+#
+# It is possible to override the default locations by altering the 'key_file',
+# 'cert_file', and 'ca_file' values and uncommenting them below.
+#
+# NB, overriding the default of one location requires uncommenting and
+# possibly additionally overriding the other settings.
+#
# Override the default server key file path
#
--
2.14.3
6 years, 11 months
[libvirt] [PATCH] libvirtd: Explicit dependency on systemd-machined
by Michal Koutný
The libvirtd daemon uses systemd-machined D-Bus API when manipulating
domains. The systemd-machined is D-Bus activated on demand.
However, during system shutdown systemd-machined is stopped concurrently
with libvirtd and virsh users also doing their final cleanup may
transitively fail due to unavailability of systemd-machined. Example
error message
> libvirtd[1390]: 2017-12-20 18:55:56.182+0000: 32700: error : virSystemdTerminateMachine:503 : Refusing activation, D-Bus is shutting down.
To circumvent this we need to explicitly specify both ordering and
requirement dependency (to avoid late D-Bus activation) on
systemd-machined. See [1] for the dependency debate.
[1] https://lists.freedesktop.org/archives/systemd-devel/2018-January/040095....
---
The Wants= dependency is for the case when systemd-machined wasn't started
neither D-Bus activated anytime before the shutdown transaction. AFAICS this is
very unlikely so for the sake of lazy activation, the Wants= hunk can be
dropped.
daemon/libvirtd.service.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/daemon/libvirtd.service.in b/daemon/libvirtd.service.in
index c189f5e65..769702ea7 100644
--- a/daemon/libvirtd.service.in
+++ b/daemon/libvirtd.service.in
@@ -7,6 +7,7 @@
Description=Virtualization daemon
Requires=virtlogd.socket
Requires=virtlockd.socket
+Wants=systemd-machined.service
Before=libvirt-guests.service
After=network.target
After=dbus.service
@@ -14,6 +15,7 @@ After=iscsid.service
After=apparmor.service
After=local-fs.target
After=remote-fs.target
+After=systemd-machined.service
Documentation=man:libvirtd(8)
Documentation=https://libvirt.org
--
2.13.6
6 years, 11 months
[libvirt] [PATCH 0/4] Add admin protocol support for virtlogd/virtlockd
by Daniel P. Berrange
The initial admin protocol support was only integrated into libvirtd.
This series extracts that code so that it is reusable with all the
daemons we have (and more than we'll get).
Daniel P. Berrange (4):
admin: move admins server impl/dispatch into src/admin directory
util: add virGetUNIXSocketPath helper
logd: add support for admin protocol in virtlogd
lockd: add support for admin protocol in virtlockd
.gitignore | 1 +
cfg.mk | 3 +-
daemon/Makefile.am | 33 +----
daemon/libvirtd.c | 2 +-
daemon/libvirtd.h | 10 --
po/POTFILES.in | 4 +-
src/Makefile.am | 33 ++++-
{daemon => src/admin}/admin_server.c | 4 +-
{daemon => src/admin}/admin_server.h | 6 +-
.../admin.c => src/admin/admin_server_dispatch.c | 21 ++--
.../admin.h => src/admin/admin_server_dispatch.h | 9 +-
src/libvirt-admin.c | 23 +++-
src/locking/lock_daemon.c | 132 +++++++++++++++-----
src/locking/lock_daemon_config.c | 3 +
src/locking/lock_daemon_config.h | 1 +
src/locking/test_virtlockd.aug.in | 4 +
src/locking/virtlockd-admin.socket.in | 10 ++
src/locking/virtlockd.aug | 1 +
src/locking/virtlockd.conf | 6 +
src/locking/virtlockd.service.in | 1 +
src/logging/log_daemon.c | 135 +++++++++++++++------
src/logging/log_daemon_config.c | 3 +
src/logging/log_daemon_config.h | 1 +
src/logging/test_virtlogd.aug.in | 4 +
src/logging/virtlogd-admin.socket.in | 10 ++
src/logging/virtlogd.aug | 1 +
src/logging/virtlogd.service.in | 1 +
src/util/virutil.c | 45 +++++++
src/util/virutil.h | 1 +
29 files changed, 371 insertions(+), 137 deletions(-)
rename {daemon => src/admin}/admin_server.c (99%)
rename {daemon => src/admin}/admin_server.h (96%)
rename daemon/admin.c => src/admin/admin_server_dispatch.c (96%)
rename daemon/admin.h => src/admin/admin_server_dispatch.h (83%)
create mode 100644 src/locking/virtlockd-admin.socket.in
create mode 100644 src/logging/virtlogd-admin.socket.in
--
2.14.3
6 years, 11 months
[libvirt] [PATCH] qemu: Don't initialize struct utsname
by Jiri Denemark
It breaks the build and it is not really useful for anything.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Pushed under the build breaker rule.
src/qemu/qemu_capabilities.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2c573827f1..5e03447baa 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5431,7 +5431,7 @@ virQEMUCapsCacheNew(const char *libDir,
char *capsCacheDir = NULL;
virFileCachePtr cache = NULL;
virQEMUCapsCachePrivPtr priv = NULL;
- struct utsname uts = { 0 };
+ struct utsname uts;
if (virAsprintf(&capsCacheDir, "%s/capabilities", cacheDir) < 0)
goto error;
--
2.16.0
6 years, 11 months
[libvirt] [PATCH] Raise the frame limit for tests
by Ján Tomko
After the latest CPU additions, the build fails with clang:
cputest.c:905:1: error: stack frame size of 26136 bytes
in function 'mymain' [-Werror,-Wframe-larger-than=]
Raise the relaxed limit which is used for tests.
---
m4/virt-compile-warnings.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Pushed as a build breaker fix
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index f18a08a8f..b9c974842 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -200,7 +200,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
# but using 1024 bytes sized buffers (mostly for virStrerror)
# stops us from going down further
gl_WARN_ADD([-Wframe-larger-than=4096], [STRICT_FRAME_LIMIT_CFLAGS])
- gl_WARN_ADD([-Wframe-larger-than=25600], [RELAXED_FRAME_LIMIT_CFLAGS])
+ gl_WARN_ADD([-Wframe-larger-than=32768], [RELAXED_FRAME_LIMIT_CFLAGS])
# Extra special flags
dnl -fstack-protector stuff passes gl_WARN_ADD with gcc
--
2.13.6
6 years, 11 months
[libvirt] [PATCH] qemu: auto-add generic xhci rather than NEC xhci to Q35 domains
by Laine Stump
We recently added a generic XHCI USB3 controller to QEMU, and libvirt
supports adding that controller rather than the NEC XHCI USB3
controller, but when auto-adding a USB controller to Q35 domains we
were still adding the vendor-specific NEC controller. This patch
changes to add the generic controller instead, if it's available in
the QEMU binary that will be used.
---
src/qemu/qemu_domain.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1676c03fc..6b4bd3cca 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2660,12 +2660,13 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
addPCIeRoot = true;
addImplicitSATA = true;
- /* Prefer adding USB3 controller if supported
- * (nec-usb-xhci). Failing that, add a USB2 controller set
- * if the ich9-usb-ehci1 device is supported. Otherwise
- * don't add anything.
+ /* Prefer adding a USB3 controller if supported, fall back
+ * to USB2 if there is no USB3 available, and if that's
+ * unavailable don't add anything.
*/
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
+ usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
+ else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_USB_EHCI1))
usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1;
--
2.14.3
6 years, 11 months
[libvirt] [PATCH v2] libvirtd: clarify the TLS conf default vaule setting
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
As the description of daemon/libvirtd.conf, setting
key_file, cert_file or key_file will override the default value.
But if we set any one of them, we need to set all the rest of them.
This patch clarify that description.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
v2:
fix a typo
daemon/libvirtd.conf | 3 +++
1 file changed, 3 insertions(+)
diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
index 8e0c0d96d..7040ff26b 100644
--- a/daemon/libvirtd.conf
+++ b/daemon/libvirtd.conf
@@ -183,6 +183,9 @@
#
+# NB, if the default value of 'key_file', 'cert_file' or
+# 'ca_file' would be changed,
+# all of them should be changed together.
# Override the default server key file path
#
#key_file = "/etc/pki/libvirt/private/serverkey.pem"
--
2.14.3
6 years, 11 months
[libvirt] [PATCH] add support of iSER transport type in qemu with libiscsi
by lichstor@gmail.com
From: zhangshengyu <zhangshengyu(a)fusionstack.cn>
---
docs/schemas/domaincommon.rng | 28 +++++++++++++
src/conf/domain_conf.c | 8 ++++
src/qemu/qemu_block.c | 24 ++++++++++-
src/qemu/qemu_command.c | 3 ++
src/qemu/qemu_parse_command.c | 10 ++++-
src/storage/storage_backend_gluster.c | 1 +
src/util/virstoragefile.c | 3 +-
src/util/virstoragefile.h | 1 +
.../disk-drive-network-iser-auth.args | 25 ++++++++++++
.../disk-drive-network-iser-auth.xml | 44 ++++++++++++++++++++
.../qemuargv2xmldata/disk-drive-network-iser.args | 25 ++++++++++++
tests/qemuargv2xmldata/disk-drive-network-iser.xml | 41 +++++++++++++++++++
tests/qemuargv2xmltest.c | 2 +
...-drive-network-iser-auth-secrettype-invalid.xml | 33 +++++++++++++++
...sk-drive-network-iser-auth-wrong-secrettype.xml | 33 +++++++++++++++
.../disk-drive-network-iser-auth.args | 31 ++++++++++++++
.../disk-drive-network-iser-auth.xml | 43 ++++++++++++++++++++
.../disk-drive-network-iser-lun.args | 27 +++++++++++++
.../disk-drive-network-iser-lun.xml | 28 +++++++++++++
.../qemuxml2argvdata/disk-drive-network-iser.args | 29 +++++++++++++
tests/qemuxml2argvdata/disk-drive-network-iser.xml | 37 +++++++++++++++++
tests/qemuxml2argvtest.c | 7 ++++
.../disk-drive-network-iser-auth.xml | 47 ++++++++++++++++++++++
.../qemuxml2xmloutdata/disk-drive-network-iser.xml | 41 +++++++++++++++++++
tests/qemuxml2xmltest.c | 2 +
25 files changed, 569 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuargv2xmldata/disk-drive-network-iser-auth.args
create mode 100644 tests/qemuargv2xmldata/disk-drive-network-iser-auth.xml
create mode 100644 tests/qemuargv2xmldata/disk-drive-network-iser.args
create mode 100644 tests/qemuargv2xmldata/disk-drive-network-iser.xml
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser-auth-secrettype-invalid.xml
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser-auth-wrong-secrettype.xml
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser-auth.args
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser-auth.xml
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser-lun.args
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser-lun.xml
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser.args
create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-drive-network-iser-auth.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-drive-network-iser.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f22c932f6..819a8791d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1534,6 +1534,7 @@
<choice>
<value>tcp</value>
<value>rdma</value>
+ <value>iser</value>
</choice>
</attribute>
</optional>
@@ -1613,6 +1614,15 @@
<optional>
<ref name="encryption"/>
</optional>
+ <optional>
+ <attribute name="transport">
+ <choice>
+ <value>tcp</value>
+ <value>rdma</value>
+ <value>iser</value>
+ </choice>
+ </attribute>
+ </optional>
</element>
</define>
@@ -4386,6 +4396,15 @@
<attribute name="name">
<text/>
</attribute>
+ <optional>
+ <attribute name="transport">
+ <choice>
+ <value>tcp</value>
+ <value>rdma</value>
+ <value>iser</value>
+ </choice>
+ </attribute>
+ </optional>
<interleave>
<oneOrMore>
<element name='host'>
@@ -4397,6 +4416,15 @@
<ref name="PortNumber"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="transport">
+ <choice>
+ <value>tcp</value>
+ <value>rdma</value>
+ <value>iser</value>
+ </choice>
+ </attribute>
+ </optional>
<empty/>
</element>
</oneOrMore>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a1c25060f..8aa193ac2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7075,6 +7075,7 @@ virDomainStorageNetworkParseHosts(xmlNodePtr node,
virStorageNetHostDefPtr *hosts,
size_t *nhosts)
{
+ char *transport = NULL;
xmlNodePtr child;
for (child = node->children; child; child = child->next) {
@@ -7086,6 +7087,9 @@ virDomainStorageNetworkParseHosts(xmlNodePtr node,
}
}
+ if ((*hosts) && (transport = virXMLPropString(node, "transport")))
+ (*hosts)->transport = virStorageNetHostTransportTypeFromString(transport);
+
return 0;
}
@@ -8490,6 +8494,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts) < 0)
goto cleanup;
+
virStorageSourceNetworkAssignDefaultPorts(src);
ret = 0;
@@ -22371,6 +22376,9 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
VIR_FREE(path);
+ if (src->hosts && src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_ISER)
+ virBufferEscapeString(attrBuf, " transport='%s'", "iser");
+
if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT &&
!(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
src->tlsFromConfig))
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 585f0255e..49837205f 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -433,6 +433,12 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src)
if (VIR_STRDUP(uri->scheme,
virStorageNetProtocolTypeToString(src->protocol)) < 0)
goto cleanup;
+ } else if (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_ISER) {
+ uri->port = src->hosts->port;
+
+ if (VIR_STRDUP(uri->scheme,
+ virStorageNetHostTransportTypeToString(src->hosts->transport)) < 0)
+ goto cleanup;
} else {
if (virAsprintf(&uri->scheme, "%s+%s",
virStorageNetProtocolTypeToString(src->protocol),
@@ -506,6 +512,19 @@ qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDefPtr host,
goto cleanup;
break;
+ case VIR_STORAGE_NET_HOST_TRANS_ISER:
+ transport = "iser";
+ if (virAsprintf(&port, "%u", host->port) < 0)
+ goto cleanup;
+
+ if (virJSONValueObjectCreate(&server,
+ "s:type", transport,
+ "s:host", host->name,
+ "s:port", port,
+ NULL) < 0)
+ goto cleanup;
+ break;
+
case VIR_STORAGE_NET_HOST_TRANS_UNIX:
if (virJSONValueObjectCreate(&server,
"s:type", "unix",
@@ -590,7 +609,8 @@ qemuBlockStorageSourceBuildJSONInetSocketAddress(virStorageNetHostDefPtr host)
virJSONValuePtr ret = NULL;
char *port = NULL;
- if (host->transport != VIR_STORAGE_NET_HOST_TRANS_TCP) {
+ if (host->transport != VIR_STORAGE_NET_HOST_TRANS_TCP &&
+ host->transport != VIR_STORAGE_NET_HOST_TRANS_ISER) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("only TCP protocol can be converted to InetSocketAddress"));
return NULL;
@@ -831,7 +851,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src)
"s:portal", portal,
"s:target", target,
"u:lun", lun,
- "s:transport", "tcp",
+ "s:transport", virStorageNetHostTransportTypeToString(src->hosts->transport),
"S:user", username,
"S:password-secret", objalias,
NULL));
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b8aede32d..dd6e3be9a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -883,6 +883,8 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
if (!((src->hosts->name && strchr(src->hosts->name, ':')) ||
(src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP &&
!src->hosts->name) ||
+ (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_ISER &&
+ !src->hosts->name) ||
(src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_UNIX &&
src->hosts->socket &&
src->hosts->socket[0] != '/'))) {
@@ -891,6 +893,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
switch (src->hosts->transport) {
case VIR_STORAGE_NET_HOST_TRANS_TCP:
+ case VIR_STORAGE_NET_HOST_TRANS_ISER:
virBufferAsprintf(&buf, "%s:%u",
src->hosts->name, src->hosts->port);
break;
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 5fe3f97d0..d376af208 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -70,7 +70,9 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
if (transp)
*transp++ = 0;
- if (STRNEQ(uri->scheme, scheme)) {
+ if (STREQ(uri->scheme, "iser")) {
+ transp = (char *)"iser";
+ } else if (STRNEQ(uri->scheme, scheme)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid transport/scheme '%s'"), uri->scheme);
goto error;
@@ -709,6 +711,12 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
if (qemuParseISCSIString(def) < 0)
goto error;
+ } else if (STRPREFIX(def->src->path, "iser:")) {
+ def->src->type = VIR_STORAGE_TYPE_NETWORK;
+ def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
+
+ if (qemuParseISCSIString(def) < 0)
+ goto error;
} else if (STRPREFIX(def->src->path, "sheepdog:")) {
char *p = def->src->path;
char *port, *vdi;
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 5eea84f16..1452fa0cd 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -608,6 +608,7 @@ virStorageFileBackendGlusterInitServer(virStorageFileBackendGlusterPrivPtr priv,
hoststr = host->socket;
break;
+ case VIR_STORAGE_NET_HOST_TRANS_ISER:
case VIR_STORAGE_NET_HOST_TRANS_LAST:
break;
}
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 5780180a9..63253a9c4 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -92,7 +92,8 @@ VIR_ENUM_IMPL(virStorageNetProtocol, VIR_STORAGE_NET_PROTOCOL_LAST,
VIR_ENUM_IMPL(virStorageNetHostTransport, VIR_STORAGE_NET_HOST_TRANS_LAST,
"tcp",
"unix",
- "rdma")
+ "rdma",
+ "iser")
VIR_ENUM_IMPL(virStorageSourcePoolMode,
VIR_STORAGE_SOURCE_POOL_MODE_LAST,
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index ecd806c93..5a6ec7776 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -147,6 +147,7 @@ typedef enum {
VIR_STORAGE_NET_HOST_TRANS_TCP,
VIR_STORAGE_NET_HOST_TRANS_UNIX,
VIR_STORAGE_NET_HOST_TRANS_RDMA,
+ VIR_STORAGE_NET_HOST_TRANS_ISER,
VIR_STORAGE_NET_HOST_TRANS_LAST
} virStorageNetHostTransport;
diff --git a/tests/qemuargv2xmldata/disk-drive-network-iser-auth.args b/tests/qemuargv2xmldata/disk-drive-network-iser-auth.args
new file mode 100644
index 000000000..aaf10d8c8
--- /dev/null
+++ b/tests/qemuargv2xmldata/disk-drive-network-iser-auth.args
@@ -0,0 +1,25 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=iser://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A@example.org:\
+6000/iqn.1992-01.com.example%3Astorage/1,format=raw,if=virtio \
+-drive file=iser://example.org:6000/iqn.1992-01.com.example%3Astorage/2,\
+format=raw,if=virtio \
+-net none \
+-serial none \
+-parallel none
diff --git a/tests/qemuargv2xmldata/disk-drive-network-iser-auth.xml b/tests/qemuargv2xmldata/disk-drive-network-iser-auth.xml
new file mode 100644
index 000000000..7226443fb
--- /dev/null
+++ b/tests/qemuargv2xmldata/disk-drive-network-iser-auth.xml
@@ -0,0 +1,44 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <auth username='myname'>
+ <secret type='iscsi' usage='qemuargv2xml_usage'/>
+ </auth>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/1' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/2' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vdb' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmldata/disk-drive-network-iser.args b/tests/qemuargv2xmldata/disk-drive-network-iser.args
new file mode 100644
index 000000000..c476e759e
--- /dev/null
+++ b/tests/qemuargv2xmldata/disk-drive-network-iser.args
@@ -0,0 +1,25 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=iser://example.org:6000/iqn.1992-01.com.example,format=raw,\
+if=virtio \
+-drive file=iser://example.org:6000/iqn.1992-01.com.example/1,format=raw,\
+if=virtio \
+-net none \
+-serial none \
+-parallel none
diff --git a/tests/qemuargv2xmldata/disk-drive-network-iser.xml b/tests/qemuargv2xmldata/disk-drive-network-iser.xml
new file mode 100644
index 000000000..88f043f66
--- /dev/null
+++ b/tests/qemuargv2xmldata/disk-drive-network-iser.xml
@@ -0,0 +1,41 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/0' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/1' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vdb' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index cb010268c..59b26c647 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -213,6 +213,8 @@ mymain(void)
DO_TEST("disk-drive-network-nbd-unix");
DO_TEST("disk-drive-network-iscsi");
DO_TEST("disk-drive-network-iscsi-auth");
+ DO_TEST("disk-drive-network-iser");
+ DO_TEST("disk-drive-network-iser-auth");
DO_TEST("disk-drive-network-gluster");
DO_TEST("disk-drive-network-rbd");
DO_TEST("disk-drive-network-rbd-auth");
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser-auth-secrettype-invalid.xml b/tests/qemuxml2argvdata/disk-drive-network-iser-auth-secrettype-invalid.xml
new file mode 100644
index 000000000..dbcf484dc
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser-auth-secrettype-invalid.xml
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <auth username='myname'>
+ <secret usage='mycluster_myname'/>
+ </auth>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/1' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser-auth-wrong-secrettype.xml b/tests/qemuxml2argvdata/disk-drive-network-iser-auth-wrong-secrettype.xml
new file mode 100644
index 000000000..5525e9d86
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser-auth-wrong-secrettype.xml
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <auth username='myname'>
+ <secret type='ceph' usage='mycluster_myname'/>
+ </auth>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/1' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser-auth.args b/tests/qemuxml2argvdata/disk-drive-network-iser-auth.args
new file mode 100644
index 000000000..5fa7a04bb
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser-auth.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=iser://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A@example.org:\
+6000/iqn.1992-01.com.example%3Astorage/1,format=raw,if=none,\
+id=drive-virtio-disk0 \
+-device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
+id=virtio-disk0 \
+-drive file=iser://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A@example.org:\
+6000/iqn.1992-01.com.example%3Astorage/2,format=raw,if=none,\
+id=drive-virtio-disk1 \
+-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk1,\
+id=virtio-disk1
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser-auth.xml b/tests/qemuxml2argvdata/disk-drive-network-iser-auth.xml
new file mode 100644
index 000000000..fbcb6b4f1
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser-auth.xml
@@ -0,0 +1,43 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <auth username='myname'>
+ <secret type='iscsi' usage='mycluster_myname'/>
+ </auth>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/1' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <auth username='myname'>
+ <secret type='iscsi' usage='mycluster_myname'/>
+ </auth>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/2' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vdb' bus='virtio'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser-lun.args b/tests/qemuxml2argvdata/disk-drive-network-iser-lun.args
new file mode 100644
index 000000000..d9428533b
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser-lun.args
@@ -0,0 +1,27 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi \
+-boot c \
+-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
+-usb \
+-drive file=iser://example.org:3260/iqn.1992-01.com.example/0,format=raw,\
+if=none,id=drive-scsi0-0-0-0 \
+-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
+drive=drive-scsi0-0-0-0,id=scsi0-0-0-0
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser-lun.xml b/tests/qemuxml2argvdata/disk-drive-network-iser-lun.xml
new file mode 100644
index 000000000..25fa76140
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser-lun.xml
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='lun'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example' transport='iser'>
+ <host name='example.org' port='3260' transport='iser'/>
+ </source>
+ <target dev='sda' bus='scsi'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser.args b/tests/qemuxml2argvdata/disk-drive-network-iser.args
new file mode 100644
index 000000000..49ea467ff
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=iser://example.org:6000/iqn.1992-01.com.example/0,format=raw,\
+if=none,id=drive-virtio-disk0 \
+-device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
+id=virtio-disk0 \
+-drive file=iser://example.org:6000/iqn.1992-01.com.example/1,format=raw,\
+if=none,id=drive-virtio-disk1 \
+-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk1,\
+id=virtio-disk1
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser.xml b/tests/qemuxml2argvdata/disk-drive-network-iser.xml
new file mode 100644
index 000000000..b1634555c
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example' transport='iser'>
+ <host name='example.org' port='6000'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/1' transport='iser'>
+ <host name='example.org' port='6000'/>
+ </source>
+ <target dev='vdb' bus='virtio'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index be32d891e..dcb35f017 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -939,6 +939,13 @@ mymain(void)
DO_TEST("disk-drive-network-iscsi-lun",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI,
QEMU_CAPS_SCSI_BLOCK);
+ DO_TEST("disk-drive-network-iser", NONE);
+ DO_TEST("disk-drive-network-iser-auth", NONE);
+ DO_TEST_PARSE_ERROR("disk-drive-network-iser-auth-secrettype-invalid", NONE);
+ DO_TEST_PARSE_ERROR("disk-drive-network-iser-auth-wrong-secrettype", NONE);
+ DO_TEST("disk-drive-network-iser-lun",
+ QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI,
+ QEMU_CAPS_SCSI_BLOCK);
DO_TEST("disk-drive-network-gluster",
QEMU_CAPS_GLUSTER_DEBUG_LEVEL);
DO_TEST("disk-drive-network-rbd", NONE);
diff --git a/tests/qemuxml2xmloutdata/disk-drive-network-iser-auth.xml b/tests/qemuxml2xmloutdata/disk-drive-network-iser-auth.xml
new file mode 100644
index 000000000..1b27fdea2
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-drive-network-iser-auth.xml
@@ -0,0 +1,47 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <auth username='myname'>
+ <secret type='iscsi' usage='mycluster_myname'/>
+ </auth>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/1' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <auth username='myname'>
+ <secret type='iscsi' usage='mycluster_myname'/>
+ </auth>
+ <source protocol='iscsi' name='iqn.1992-01.com.example:storage/2' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vdb' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/disk-drive-network-iser.xml b/tests/qemuxml2xmloutdata/disk-drive-network-iser.xml
new file mode 100644
index 000000000..88f043f66
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-drive-network-iser.xml
@@ -0,0 +1,41 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/0' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi' name='iqn.1992-01.com.example/1' transport='iser'>
+ <host name='example.org' port='6000' transport='iser'/>
+ </source>
+ <target dev='vdb' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2be8eb2c1..aeeda2dd1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -515,6 +515,8 @@ mymain(void)
DO_TEST("disk-drive-network-nbd-unix", NONE);
DO_TEST("disk-drive-network-iscsi", NONE);
DO_TEST("disk-drive-network-iscsi-auth", NONE);
+ DO_TEST("disk-drive-network-iser", NONE);
+ DO_TEST("disk-drive-network-iser-auth", NONE);
DO_TEST("disk-drive-network-gluster", NONE);
DO_TEST("disk-drive-network-rbd", NONE);
DO_TEST("disk-drive-network-rbd-auth", NONE);
--
2.13.6 (Apple Git-96)
6 years, 11 months
[libvirt] [PATCH V3] nodedev: Fix failing to parse PCI address for non-PCI network devices
by Jim Fehlig
Commit 8708ca01c added virNetDevSwitchdevFeature() to check if a network
device has Switchdev capabilities. virNetDevSwitchdevFeature() attempts
to retrieve the PCI device associated with the network device, ignoring
non-PCI devices. It does so via the following call chain
virNetDevSwitchdevFeature()->virNetDevGetPCIDevice()->
virPCIGetDeviceAddressFromSysfsLink()
For non-PCI network devices (qeth, Xen vif, etc),
virPCIGetDeviceAddressFromSysfsLink() will report an error when
virPCIDeviceAddressParse() fails. virPCIDeviceAddressParse() also
logs an error. After commit 8708ca01c there are now two errors reported
for each non-PCI network device even though the errors are harmless.
To avoid the errors, introduce virNetDevIsPCIDevice() and use it in
virNetDevGetPCIDevice() before attempting to retrieve the associated
PCI device. virNetDevIsPCIDevice() uses the 'subsystem' property of the
device to determine if it is PCI. See the sysfs rules in kernel
documentation for more details
https://www.kernel.org/doc/html/latest/admin-guide/sysfs-rules.html
---
V2: https://www.redhat.com/archives/libvir-list/2018-January/msg00233.html
Changes in V3:
Implement checking if netdev is PCI in virnetdev.c instead of virpci.c
Addressed other comments from eskultet
src/util/virnetdev.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index eb2d119bf..baf4a71fe 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -22,6 +22,7 @@
#include <config.h>
+#include "dirname.h"
#include "virnetdev.h"
#include "virnetlink.h"
#include "virmacaddr.h"
@@ -1147,6 +1148,48 @@ virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname,
return 0;
}
+/**
+ * Determine if the device path specified in devpath is a PCI Device
+ * by resolving the 'subsystem'-link in devpath and looking for
+ * 'pci' in the last component. For more information see the rules
+ * for accessing sysfs in the kernel docs
+ *
+ * https://www.kernel.org/doc/html/latest/admin-guide/sysfs-rules.html
+ *
+ * Returns true if devpath's susbsystem is pci, false otherwise.
+ */
+static bool
+virNetDevIsPCIDevice(const char *devpath)
+{
+ char *subsys_link = NULL;
+ char *abs_path = NULL;
+ char *subsys = NULL;
+ bool ret = false;
+
+ if (virAsprintf(&subsys_link, "%s/subsystem", devpath) < 0)
+ return false;
+
+ if (!virFileExists(subsys_link))
+ goto cleanup;
+
+ if (virFileIsLink(subsys_link) != 1)
+ goto cleanup;
+
+ if (virFileResolveLink(subsys_link, &abs_path) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to resolve device subsystem symlink %s"),
+ subsys_link);
+ goto cleanup;
+ }
+
+ subsys = last_component(abs_path);
+ ret = STRPREFIX(subsys, "pci");
+
+ cleanup:
+ VIR_FREE(subsys_link);
+ VIR_FREE(abs_path);
+ return ret;
+}
static virPCIDevicePtr
virNetDevGetPCIDevice(const char *devName)
@@ -1158,6 +1201,9 @@ virNetDevGetPCIDevice(const char *devName)
if (virNetDevSysfsFile(&vfSysfsDevicePath, devName, "device") < 0)
goto cleanup;
+ if (!virNetDevIsPCIDevice(vfSysfsDevicePath))
+ goto cleanup;
+
vfPCIAddr = virPCIGetDeviceAddressFromSysfsLink(vfSysfsDevicePath);
if (!vfPCIAddr)
goto cleanup;
--
2.15.1
6 years, 11 months