[libvirt] [PATCH] bhyve: add vga configuration for video driver
by Roman Bogorodskiy
Add support for vgaconf driver configuration. In domain xml it looks like
this:
<video>
<driver vgaconf='io|on|off'>
<model .../>
</video>
It was added with bhyve gop video in mind to allow users control how the
video device is exposed to the guest, specifically, how VGA I/O is
handled.
One can refer to the bhyve manual page to get more detailed description
of the possible VGA configuration options:
https://www.freebsd.org/cgi/man.cgi?query=bhyve&manpath=FreeBSD+12-current
The relevant part could be found using the 'vgaconf' keyword.
Also, add some tests for this new feature.
Signed-off-by: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
---
Changes from v1:
* Rebased on top of current master. Specifically, the most important bit
was merging with f5384fb4 which has added video/driver element
* In conjunction with f5384fb4 use video/driver element instead of
video/model/driver
* Squash in conf and bhyve patches to make it easier to understand how
it's used
* Rename *Vgaconf* to *VGAConf*
* Add a little more tests
docs/schemas/domaincommon.rng | 13 ++++-
src/bhyve/bhyve_command.c | 4 ++
src/conf/domain_conf.c | 57 ++++++++++++++++++++--
src/conf/domain_conf.h | 17 +++++++
src/libvirt_private.syms | 2 +
.../bhyvexml2argv-vnc-vgaconf-io.args | 12 +++++
.../bhyvexml2argv-vnc-vgaconf-io.ldargs | 1 +
.../bhyvexml2argv-vnc-vgaconf-io.xml | 30 ++++++++++++
.../bhyvexml2argv-vnc-vgaconf-off.args | 12 +++++
.../bhyvexml2argv-vnc-vgaconf-off.ldargs | 1 +
.../bhyvexml2argv-vnc-vgaconf-off.xml | 30 ++++++++++++
.../bhyvexml2argv-vnc-vgaconf-on.args | 12 +++++
.../bhyvexml2argv-vnc-vgaconf-on.ldargs | 1 +
.../bhyvexml2argv-vnc-vgaconf-on.xml | 30 ++++++++++++
tests/bhyvexml2argvtest.c | 3 ++
.../bhyvexml2xmlout-vnc-vgaconf-io.xml | 41 ++++++++++++++++
.../bhyvexml2xmlout-vnc-vgaconf-off.xml | 42 ++++++++++++++++
.../bhyvexml2xmlout-vnc-vgaconf-on.xml | 42 ++++++++++++++++
tests/bhyvexml2xmltest.c | 3 ++
19 files changed, 348 insertions(+), 5 deletions(-)
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-io.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-off.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-on.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4950ddc10..51acac3ee 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3220,7 +3220,18 @@
<element name="video">
<optional>
<element name="driver">
- <ref name="virtioOptions"/>
+ <optional>
+ <ref name="virtioOptions"/>
+ </optional>
+ <optional>
+ <attribute name="vgaconf">
+ <choice>
+ <value>io</value>
+ <value>on</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ </optional>
</element>
</optional>
<optional>
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index eae5cb3ca..b3ae315bd 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -408,6 +408,10 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
_("Unsupported listen type"));
}
+ if (video->driver)
+ virBufferAsprintf(&opt, ",vga=%s",
+ virDomainVideoVGAConfTypeToString(video->driver->vgaconf));
+
virCommandAddArg(cmd, "-s");
virCommandAddArgBuffer(cmd, &opt);
return 0;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4f79d3825..1e9f91ca8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -560,6 +560,11 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"virtio",
"gop")
+VIR_ENUM_IMPL(virDomainVideoVGAConf, VIR_DOMAIN_VIDEO_VGACONF_LAST,
+ "io",
+ "on",
+ "off")
+
VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
"mouse",
"tablet",
@@ -2355,6 +2360,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
VIR_FREE(def->accel);
VIR_FREE(def->virtio);
+ VIR_FREE(def->driver);
VIR_FREE(def);
}
@@ -13529,6 +13535,43 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
return def;
}
+static virDomainVideoDriverDefPtr
+virDomainVideoDriverDefParseXML(xmlNodePtr node)
+{
+ xmlNodePtr cur;
+ virDomainVideoDriverDefPtr def;
+ char *vgaconf = NULL;
+ int val;
+
+ cur = node->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if (!vgaconf &&
+ xmlStrEqual(cur->name, BAD_CAST "driver")) {
+ vgaconf = virXMLPropString(cur, "vgaconf");
+ }
+ }
+ cur = cur->next;
+ }
+
+ if (!vgaconf)
+ return NULL;
+
+ if (VIR_ALLOC(def) < 0)
+ goto cleanup;
+
+ if ((val = virDomainVideoVGAConfTypeFromString(vgaconf)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown vgaconf value '%s'"), vgaconf);
+ goto cleanup;
+ }
+ def->vgaconf = val;
+
+ cleanup:
+ VIR_FREE(vgaconf);
+ return def;
+}
+
static virDomainVideoDefPtr
virDomainVideoDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt,
@@ -13652,6 +13695,8 @@ virDomainVideoDefParseXML(xmlNodePtr node,
if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
goto error;
+ def->driver = virDomainVideoDriverDefParseXML(node);
+
cleanup:
ctxt->node = saved;
@@ -23386,7 +23431,6 @@ virDomainVideoAccelDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
-
static int
virDomainVideoDefFormat(virBufferPtr buf,
virDomainVideoDefPtr def,
@@ -23406,9 +23450,13 @@ virDomainVideoDefFormat(virBufferPtr buf,
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
if (virBufferCheckError(&driverBuf) < 0)
return -1;
- if (virBufferUse(&driverBuf)) {
+ if (virBufferUse(&driverBuf) || (def->driver && def->driver->vgaconf)) {
virBufferAddLit(buf, "<driver");
- virBufferAddBuffer(buf, &driverBuf);
+ if (virBufferUse(&driverBuf))
+ virBufferAddBuffer(buf, &driverBuf);
+ if (def->driver && def->driver->vgaconf)
+ virBufferAsprintf(buf, " vgaconf='%s'",
+ virDomainVideoVGAConfTypeToString(def->driver->vgaconf));
virBufferAddLit(buf, "/>\n");
}
virBufferAsprintf(buf, "<model type='%s'",
@@ -23428,7 +23476,8 @@ virDomainVideoDefFormat(virBufferPtr buf,
if (def->accel) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
- virDomainVideoAccelDefFormat(buf, def->accel);
+ if (def->accel)
+ virDomainVideoAccelDefFormat(buf, def->accel);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</model>\n");
} else {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6d9ee9787..964bc02f9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1359,6 +1359,16 @@ typedef enum {
} virDomainVideoType;
+typedef enum {
+ VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
+ VIR_DOMAIN_VIDEO_VGACONF_ON,
+ VIR_DOMAIN_VIDEO_VGACONF_OFF,
+
+ VIR_DOMAIN_VIDEO_VGACONF_LAST
+} virDomainVideoVGAConf;
+
+VIR_ENUM_DECL(virDomainVideoVGAConf)
+
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
@@ -1367,6 +1377,12 @@ struct _virDomainVideoAccelDef {
};
+typedef struct _virDomainVideoDriverDef virDomainVideoDriverDef;
+typedef virDomainVideoDriverDef *virDomainVideoDriverDefPtr;
+struct _virDomainVideoDriverDef {
+ virDomainVideoVGAConf vgaconf;
+};
+
struct _virDomainVideoDef {
int type;
unsigned int ram; /* kibibytes (multiples of 1024) */
@@ -1376,6 +1392,7 @@ struct _virDomainVideoDef {
unsigned int heads;
bool primary;
virDomainVideoAccelDefPtr accel;
+ virDomainVideoDriverDefPtr driver;
virDomainDeviceInfo info;
virDomainVirtioOptionsPtr virtio;
};
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 044510f09..41ca62631 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -530,6 +530,8 @@ virDomainVideoDefaultType;
virDomainVideoDefFree;
virDomainVideoTypeFromString;
virDomainVideoTypeToString;
+virDomainVideoVGAConfTypeFromString;
+virDomainVideoVGAConfTypeToString;
virDomainVirtTypeFromString;
virDomainVirtTypeToString;
virDomainWatchdogActionTypeFromString;
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.args
new file mode 100644
index 000000000..da3797100
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.args
@@ -0,0 +1,12 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 4:0,fbuf,tcp=127.0.0.1:5904,vga=io \
+-s 1,lpc bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.ldargs
new file mode 100644
index 000000000..421376db9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.xml
new file mode 100644
index 000000000..b1bb3793d
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-io.xml
@@ -0,0 +1,30 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader readonly="yes" type="pflash">/path/to/test.fd</loader>
+ </os>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <driver vgaconf="io"/>
+ <model type='gop' heads='1' primary='yes'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.args
new file mode 100644
index 000000000..70347ee0b
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.args
@@ -0,0 +1,12 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 4:0,fbuf,tcp=127.0.0.1:5904,vga=off \
+-s 1,lpc bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.ldargs
new file mode 100644
index 000000000..421376db9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.xml
new file mode 100644
index 000000000..6e9582840
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-off.xml
@@ -0,0 +1,30 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader readonly="yes" type="pflash">/path/to/test.fd</loader>
+ </os>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <driver vgaconf="off"/>
+ <model type='gop' heads='1' primary='yes'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.args
new file mode 100644
index 000000000..d0e1d81e2
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.args
@@ -0,0 +1,12 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 4:0,fbuf,tcp=127.0.0.1:5904,vga=on \
+-s 1,lpc bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.ldargs
new file mode 100644
index 000000000..421376db9
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.xml
new file mode 100644
index 000000000..a270f6334
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-vgaconf-on.xml
@@ -0,0 +1,30 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader readonly="yes" type="pflash">/path/to/test.fd</loader>
+ </os>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <driver vgaconf="on"/>
+ <model type='gop' heads='1' primary='yes'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index c8f8c685a..72f10ebc1 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -193,6 +193,9 @@ mymain(void)
DO_TEST("net-e1000");
DO_TEST("uefi");
DO_TEST("vnc");
+ DO_TEST("vnc-vgaconf-on");
+ DO_TEST("vnc-vgaconf-off");
+ DO_TEST("vnc-vgaconf-io");
/* Address allocation tests */
DO_TEST("addr-single-sata-disk");
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-io.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-io.xml
new file mode 100644
index 000000000..9e470e432
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-io.xml
@@ -0,0 +1,41 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:00:00:00'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <model type='gop' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-off.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-off.xml
new file mode 100644
index 000000000..89c4ceac5
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-off.xml
@@ -0,0 +1,42 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:00:00:00'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <driver vgaconf='off'/>
+ <model type='gop' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-on.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-on.xml
new file mode 100644
index 000000000..86d893936
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-vgaconf-on.xml
@@ -0,0 +1,42 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:00:00:00'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <driver vgaconf='on'/>
+ <model type='gop' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index b3759919e..8e41088a8 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -105,6 +105,9 @@ mymain(void)
DO_TEST_DIFFERENT("serial-grub");
DO_TEST_DIFFERENT("serial-grub-nocons");
DO_TEST_DIFFERENT("vnc");
+ DO_TEST_DIFFERENT("vnc-vgaconf-on");
+ DO_TEST_DIFFERENT("vnc-vgaconf-off");
+ DO_TEST_DIFFERENT("vnc-vgaconf-io");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");
--
2.13.0
7 years, 10 months
[libvirt] [PATCH] qemu: Remove coverity[negative_returns] annotation
by Andrea Bolognani
It was added in commit 6c2e4c3856c8ed48c378bf1bf357cab46271a47a
so that Coverity would not complain about passing -1 to
qemuDomainDetachThisHostDevice(), but the function is question
has changed since and so the annotation doesn't apply anymore.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 244dd5e..5247c06 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -5007,7 +5007,6 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
detach = vm->def->nets[detachidx];
if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
- /* coverity[negative_returns] */
ret = qemuDomainDetachThisHostDevice(driver, vm,
virDomainNetGetActualHostdev(detach));
goto cleanup;
--
2.7.5
7 years, 10 months
[libvirt] [PATCH v2] qemu: Pass the number of heads even with -vga qxl
by Martin Kletzander
When added in multiple previous commits, it was used only with -device
qxl(-vga), but for some QEMUs (< 1.6) we need to add this
functionality when using -vga qxl as well.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1283207
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v2:
- Do not change the domain definition
- Adjust the code so that it looks the same as other chunks before above
v1:
- https://www.redhat.com/archives/libvir-list/2017-June/msg00606.html
src/qemu/qemu_command.c | 7 ++++
.../qemuxml2argv-video-vga-qxl-heads.args | 30 ++++++++++++++
.../qemuxml2argv-video-vga-qxl-heads.xml | 47 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
4 files changed, 87 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8c12b2be086a..88ce3787d968 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4590,6 +4590,7 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
unsigned int vram = video->vram;
unsigned int vram64 = video->vram64;
unsigned int vgamem = video->vgamem;
+ unsigned int heads = video->heads;
if (ram) {
virCommandAddArg(cmd, "-global");
@@ -4613,6 +4614,12 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
dev, vgamem / 1024);
}
+ if (heads &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS)) {
+ virCommandAddArg(cmd, "-global");
+ virCommandAddArgFormat(cmd, "%s.max_outputs=%u",
+ dev, heads);
+ }
}
if (video->vram &&
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
new file mode 100644
index 000000000000..411a2eedbc4b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
@@ -0,0 +1,30 @@
+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 \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-vga qxl \
+-global qxl-vga.ram_size=67108864 \
+-global qxl-vga.vram_size=67108864 \
+-global qxl-vga.max_outputs=1 \
+-device qxl,id=video1,ram_size=67108864,vram_size=33554432,max_outputs=3,\
+bus=pci.0,addr=0x4 \
+-device qxl,id=video2,ram_size=67108864,vram_size=67108864,max_outputs=7,\
+bus=pci.0,addr=0x5 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
new file mode 100644
index 000000000000..d878ddcd6d2e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.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='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <video>
+ <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='3'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </video>
+ <video>
+ <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='7'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </video>
+ <video>
+ <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 799aea9faf54..34edc546b068 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1735,6 +1735,9 @@ mymain(void)
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_QXL_MAX_OUTPUTS);
+ DO_TEST("video-vga-qxl-heads",
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_QXL_MAX_OUTPUTS);
DO_TEST("video-qxl-noheads",
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_QXL,
--
2.13.1
7 years, 10 months
[libvirt] [PATCH] hacking: Improve 'git send-email' documentation
by Andrea Bolognani
For the benefit of first time contributors, we point out that 'git
send-email' might have to be installed separately; however, we omit
the fact that some configuration will likely be needed before it
can successfully deliver patches to the mailing list.
Some minor tweaks to the existing contents are included as well.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
docs/hacking.html.in | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index d6a574c..434fb68 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -29,8 +29,8 @@
file from zanata.</p>
</li>
- <li><p>Post patches using "git send-email", with git rename
- detection enabled. You need a one-time setup of:</p>
+ <li><p>Post patches using <code>git send-email</code>, with git
+ rename detection enabled. You need a one-time setup of:</p>
<pre>
git config diff.renames true
</pre>
@@ -52,20 +52,32 @@
git send-email --cover-letter --no-chain-reply-to --annotate \
--to=libvir-list(a)redhat.com master
</pre>
- <p>(Note that the "git send-email" subcommand may not be in
- the main git package and using it may require installation of a
- separate package, for example the "git-email" package in
- Fedora.) For a single patch you can omit
- <code>--cover-letter</code>, but a series of two or more
- patches needs a cover letter. If you get tired of typing
- <code>--to=libvir-list(a)redhat.com</code> designation you can
- set it in git config:</p>
+ <p>Note that the <code>git send-email</code> subcommand may not
+ be in the main git package and using it may require installation
+ of a separate package, for example the "git-email" package in
+ Fedora and Debian. If this is your first time using
+ <code>git send-email</code>, you might need to configure it to
+ point it to your SMTP server with something like:</p>
+<pre>
+ git config --global sendemail.smtpServer stmp.youremailprovider.net
+</pre>
+ <p>If you get tired of typing
+ <code>--to=libvir-list(a)redhat.com</code> all the time, you can
+ configure that to be automatically handled as well:</p>
<pre>
git config sendemail.to libvir-list(a)redhat.com
</pre>
+ <p>For a single patch you can omit
+ <code>--cover-letter</code>, but a series of two or more
+ patches needs a cover letter.</p>
+ <p>If everything went well, your patch should show up on the
+ <a href="https://www.redhat.com/archives/libvir-list/">libvir-list
+ archives</a> in a matter of minutes; if you still can't find it on
+ there after an hour or so, you should double-check your setup.</p>
<p>Please follow this as close as you can, especially the rebase and
- git send-email part, as it makes life easier for other developers to
- review your patch set. One should avoid sending patches as attachments,
+ <code>git send-email</code> part, as it makes life easier for other
+ developers to review your patch set.
+ One should avoid sending patches as attachments,
but rather send them in email body along with commit message. If a
developer is sending another version of the patch (e.g. to address
review comments), they are advised to note differences to previous
--
2.7.5
7 years, 10 months
[libvirt] [PATCH 1/2] util: implement virStrToDoubleSafe().
by Julio Faracco
Following the GNU Documentation, functions to convert double/float to string
and vice versa, use the locale to set the mantissa separator. Some languages
use comma and other use dot as a separator.
For example: 1,212.67 (en_US) = 1.112,67 (pt_BR).
This can be used to parse values in float/double from XML and other definition
files.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/libvirt_private.syms | 1 +
src/util/virstring.c | 31 +++++++++++++++++++++++++++++++
src/util/virstring.h | 4 ++++
3 files changed, 36 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 044510f..9d791e6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2659,6 +2659,7 @@ virStringTrimOptionalNewline;
virStrncpy;
virStrndup;
virStrToDouble;
+virStrToDoubleSafe;
virStrToLong_i;
virStrToLong_l;
virStrToLong_ll;
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 089b539..6dad00f 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -537,6 +537,37 @@ virStrToDouble(char const *s,
}
int
+virStrToDoubleSafe(char const *s,
+ char **end_ptr,
+ double *result)
+{
+ char *cur_locale = NULL;
+ char *saved_locale = NULL;
+ int ret = -1;
+
+ cur_locale = setlocale (LC_ALL, NULL);
+ if (!cur_locale)
+ return ret;
+
+ if (VIR_STRDUP(saved_locale, cur_locale) < 0)
+ goto cleanup;
+
+ if (!setlocale (LC_ALL, "C"))
+ goto cleanup;
+
+ ret = virStrToDouble(s, end_ptr, result);
+
+ // Cannot restore the locale.
+ if (!setlocale (LC_ALL, saved_locale))
+ ret = -1;
+
+ cleanup:
+ VIR_FREE(saved_locale);
+ VIR_FREE(cur_locale);
+ return ret;
+}
+
+int
virVasprintfInternal(bool report,
int domcode,
const char *filename,
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 0038a40..fa551b7 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -108,6 +108,10 @@ int virStrToDouble(char const *s,
char **end_ptr,
double *result)
ATTRIBUTE_RETURN_CHECK;
+int virStrToDoubleSafe(char const *s,
+ char **end_ptr,
+ double *result)
+ ATTRIBUTE_RETURN_CHECK;
void virSkipSpaces(const char **str) ATTRIBUTE_NONNULL(1);
void virSkipSpacesAndBackslash(const char **str) ATTRIBUTE_NONNULL(1);
--
2.7.4
7 years, 10 months
[libvirt] Making DHCP leases available to local DNS server through dnsmasq
by jean-christophe manciot
Hello everyone,
I have multiple virtual networks defined on my Server:
# virsh net-list --all
Name State Autostart Persistent
----------------------------------------------------------
default active yes yes
...
virtual-mgt-5 active yes yes
...
When a VM is started on one of them with an interface which needs the
dnsmasq DHCP server to get its IP address/len, it remains inaccessible with
the FQDN once the IP information is acquired.
The default values are used for each dnsmasq instance:
● libvirtd.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor
preset: enabled)
Active: active (running) since Sat 2017-06-10 19:48:58 CEST; 3ms ago
Docs: man:libvirtd(8)
http://libvirt.org
Main PID: 25365 (libvirtd)
Tasks: 35 (limit: 4915)
Memory: 27.1M
CPU: 28ms
CGroup: /system.slice/libvirtd.service
├─22262 /usr/sbin/dnsmasq
--conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro
--dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─22263 /usr/sbin/dnsmasq
--conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro
--dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
...
├─24061 /usr/sbin/dnsmasq
--conf-file=/var/lib/libvirt/dnsmasq/virtual-mgt-5.conf --leasefile-ro
--dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─24062 /usr/sbin/dnsmasq
--conf-file=/var/lib/libvirt/dnsmasq/virtual-mgt-5.conf --leasefile-ro
--dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
...
├─25365 /usr/sbin/libvirtd
└─25384 /usr/sbin/dnsmasq --help
I wonder whether the option "--leasefile-ro" gets in the way or not: there
must be a key=value in /etc/libvirt/qemu/networks/<virtual_network>.xml to
enable this behavior, but could not find it in the Network XML format
<https://libvirt.org/formatnetwork.html>.
The contents of my XML file are:
<network ipv6='yes'>
<name>virtual-mgt-5</name>
<uuid>193ac2c9-13fc-44a6-83f8-477790f1f470</uuid>
<forward mode='route'/>
<bridge name='virbr5' stp='on' delay='0'/>
<mac address='52:54:00:b9:ea:63'/>
<domain name='actionmystique.net'/>
<ip address='172.21.0.1' netmask='255.255.0.0'>
<dhcp>
<range start='172.21.0.1' end='172.21.255.254'/>
</dhcp>
</ip>
<ip family='ipv6' address='fc21::1' prefix='64'>
<dhcp>
<range start='fc21::1' end='fc21::fffe'/>
</dhcp>
</ip>
</network>
Any suggestion?
--
Jean-Christophe
7 years, 10 months
[libvirt] [PATCH v5 0/5] Hyper-V method invocation
by Sri Ramanujam
Changes from v4:
* Changes from review
* Added hypervFreeEmbeddedParam
Sri Ramanujam (5):
hyperv: Functions to work with invocation parameters.
hyperv: Generate object property type information.
hyperv: add hypervInvokeMethod
hyperv: support virDomainSendKey
hyperv: Add support for virDomainSetMemory
src/hyperv/hyperv_driver.c | 228 +++++++++
src/hyperv/hyperv_wmi.c | 911 ++++++++++++++++++++++++++++++++++
src/hyperv/hyperv_wmi.h | 95 +++-
src/hyperv/hyperv_wmi_classes.h | 19 +
src/hyperv/hyperv_wmi_generator.input | 116 +++++
src/hyperv/hyperv_wmi_generator.py | 15 +-
src/hyperv/openwsman.h | 4 +
7 files changed, 1386 insertions(+), 2 deletions(-)
--
2.9.4
7 years, 10 months
[libvirt] [PATCH 00/10] Add new JSON pseudo-protocol support for qemu 2.9 changes
by Peter Krempa
The conversion to proper structures in qemu 2.9 lead to a change in the JSON
pseudo protocol fields, which made them unknown to libvirt.
This patchset fixes and refactors a few helpers and then adds the new format
to the backing store string parser.
Peter Krempa (10):
util: storage: Output parsed network backing store string to debug log
util: storage: Add missing return to
virStorageSourceParseBackingJSONGluster
util: storage: make virStorageSourceParseBackingJSONGlusterHost
universal
util: storage: Split out parsing of TCP network host from JSON
pseudoprotocol
util: storage: Report errors when source host data is missing
util: storage: Add JSON parser for new options in iSCSI protocol
util: storage: adapt to changes in JSON format for NBD
util: storage: adapt to changes in JSON format for ceph/rbd
util: storage: adapt to changes in JSON format for ssh
util: storage: adapt to changes in JSON format for sheepdog
src/util/virstoragefile.c | 256 ++++++++++++++++++++++++++++++++++++----------
tests/virstoragetest.c | 62 +++++++++++
2 files changed, 266 insertions(+), 52 deletions(-)
--
2.12.2
7 years, 10 months
[libvirt] [PATCH 0/3] Couple of qemu NS fixes
by Michal Privoznik
Yet again, some corner cases, nothing critical.
But it is certainly nice to fix them regardless.
Michal Privoznik (3):
qemuDomainBuildNamespace: Clean up temp files
qemuDomainGetPreservedMounts: Prune nested mount points
qemuDomainGetPreservedMounts: Fix suffixes for corner cases
src/qemu/qemu_domain.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
--
2.13.0
7 years, 10 months
[libvirt] Mount events are not propagated to namespaces
by Michal Privoznik
Dear list,
while trying to fix a bug of mine, I've realized the mounts are not
being propagated into qemu namespaces once domains are running. That is,
imagine you have a domain running and then you plug in a flash disk,
mount it into host, because you have a file there that you want to
hotplug as a disk to your domain. You're not hotplugging the whole flash
disk, but a file on it. Problem is, that the mount event of the flash
disk is not propagated to qemu namespace even though the root is
remounted as MS_SLAVE|MS_REC right after the namespace is created.
After some digging. I am able to reproduce this even without libvirt at all:
# mount --make-rshared /
# mount | grep floppy
<empty/>
# unshare -m /bin/bash
# mount --make-rslave /
Now mount floppy from a different terminal:
# mount /dev/sdb1 /mnt/floppy/
# mount | grep floppy
/dev/sdb1 on /mnt/floppy type ext4 (rw,relatime,data=ordered)
At this point, mount should have been propagated into namespace. Well,
it isn't:
# mount | grep floppy
<empty/>
Do you have any idea what I am doing wrong? We need this to work not
only because of the example described above, but for a whole lot more cases.
Michal
7 years, 10 months