[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/3] bhyve: implement MSRs ignore unknown writes feature



Implement the MSRs ignore unkown writes feature that's
specified using:

  <features>
    ...
    <msrs ignoreUnknownWrites='yes'>
    ...
  </features>

in the domain XML.

In bhyve, it's just passing '-w' command line argument to the bhyve(8)
executable.

Signed-off-by: Roman Bogorodskiy <bogorodskiy gmail com>
---
 docs/drvbhyve.html.in                         | 16 +++++++++
 src/bhyve/bhyve_command.c                     |  4 +++
 .../bhyvexml2argvdata/bhyvexml2argv-msrs.args | 10 ++++++
 .../bhyvexml2argv-msrs.ldargs                 |  3 ++
 .../bhyvexml2argvdata/bhyvexml2argv-msrs.xml  | 26 ++++++++++++++
 tests/bhyvexml2argvtest.c                     |  1 +
 .../bhyvexml2xmlout-msrs.xml                  | 36 +++++++++++++++++++
 tests/bhyvexml2xmltest.c                      |  1 +
 8 files changed, 97 insertions(+)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-msrs.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-msrs.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-msrs.xml
 create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-msrs.xml

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index b4d7df2edb..5d67bf358e 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -462,5 +462,21 @@ Example:</p>
 &lt;/domain&gt;
 </pre>
 
+<h3><a id="msrsignorewrites">Ignoring unknown MSRs writes</a></h3>
+
+<p>Some guests might require ignoring unknown Model Specific Registers (MSRs) writes.
+<span class="since">Since 5.1.0</span> it's possible to switch this on using:</p>
+<pre>
+&lt;domain type="bhyve"&gt;
+    ...
+  &lt;features&gt;
+    &lt;msrs ignoreUnknownWrites='yes'/&gt;
+  &lt;/features&gt;
+    ...
+&lt;/domain&gt;
+</pre>
+
+<p>By default unknown writes are not ignored.</p>
+
   </body>
 </html>
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 84fda08943..ae2d989a95 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -505,6 +505,10 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
         virCommandAddArg(cmd, "-A"); /* Create an ACPI table */
     if (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON)
         virCommandAddArg(cmd, "-I"); /* Present ioapic to the guest */
+    if (def->features[VIR_DOMAIN_FEATURE_MSRS] == VIR_TRISTATE_SWITCH_ON) {
+        if (def->msrs_features[VIR_DOMAIN_MSRS_IGNORE_UNKNOWN_WRITES] == VIR_TRISTATE_SWITCH_ON)
+            virCommandAddArg(cmd, "-w");
+    }
 
     switch (def->clock.offset) {
     case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.args b/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.args
new file mode 100644
index 0000000000..dbe377421b
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.args
@@ -0,0 +1,10 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-w \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.ldargs
new file mode 100644
index 0000000000..32538b558e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.ldargs
@@ -0,0 +1,3 @@
+/usr/sbin/bhyveload \
+-m 214 \
+-d /tmp/freebsd.img bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.xml
new file mode 100644
index 0000000000..7543eb682c
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-msrs.xml
@@ -0,0 +1,26 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <features>
+    <msrs ignoreUnknownWrites='yes'/>
+  </features>
+  <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'>
+      <mac address='52:54:00:b9:94:02'/>
+      <model type='virtio'/>
+      <source bridge="virbr0"/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index d1b486fa64..5ea5b26466 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -210,6 +210,7 @@ mymain(void)
     DO_TEST("vnc-autoport");
     DO_TEST("cputopology");
     DO_TEST_FAILURE("cputopology-nvcpu-mismatch");
+    DO_TEST("msrs");
 
     /* Address allocation tests */
     DO_TEST("addr-single-sata-disk");
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-msrs.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-msrs.xml
new file mode 100644
index 0000000000..dcf53703bf
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-msrs.xml
@@ -0,0 +1,36 @@
+<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>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <msrs ignoreUnknownWrites='yes'/>
+  </features>
+  <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:b9:94:02'/>
+      <source bridge='virbr0'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index 6aaeab741e..916bf38c66 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -110,6 +110,7 @@ mymain(void)
     DO_TEST_DIFFERENT("vnc-vgaconf-off");
     DO_TEST_DIFFERENT("vnc-vgaconf-io");
     DO_TEST_DIFFERENT("vnc-autoport");
+    DO_TEST_DIFFERENT("msrs");
 
     /* Address allocation tests */
     DO_TEST_DIFFERENT("addr-single-sata-disk");
-- 
2.20.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]