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

Roman Bogorodskiy bogorodskiy at gmail.com
Sun Feb 10 11:09:31 UTC 2019


Implement the MSRs ignore unknown reads and writes feature
that's specified using:

  <features>
    ...
    <msrs unknown='ignore'>
    ...
  </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 at gmail.com>
---
 docs/drvbhyve.html.in                         | 22 ++++++++++++
 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, 103 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 2e9cf5551b..97f6f1b900 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -462,6 +462,23 @@ Example:</p>
 </domain>
 </pre>
 
+<h3><a id="msrsignorewrites">Ignoring unknown MSRs writes</a></h3>
+
+<p>Some guests might require ignoring unknown Model Specific Registers (MSRs)
+reads and writes.
+<span class="since">Since 5.1.0</span> it's possible to switch this on using:</p>
+<pre>
+<domain type="bhyve">
+    ...
+  <features>
+    <msrs unknown='ignore'/>
+  </features>
+    ...
+</domain>
+</pre>
+
+<p>By default unknown reads and writes are not ignored.</p>
+
 <h3><a id="bhyvecommand">Pass-through of arbitrary bhyve commands</a></h3>
 
 <p><span class="since">Since 5.1.0</span>, it's possible to pass additional command-line
@@ -489,5 +506,10 @@ They are <b>unsupported</b>, using them may result in inconsistent state,
 and upgrading either bhyve or libvirtd maybe break behavior of a domain that
 was relying on a specific commands pass-through.</p>
 
+
+>>>>>>> 525918ac5c... bhyve: implement MSRs ignore unknown writes feature
+=======
+>>>>>>> 93d9056998... fixup! bhyve: implement MSRs ignore unknown writes feature
+
   </body>
 </html>
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 1f215dac08..52ad3e3714 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -506,6 +506,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_UNKNOWN] == VIR_DOMAIN_MSRS_UNKNOWN_IGNORE)
+            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..dc9de93abc
--- /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 unknown='ignore'/>
+  </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 4a7f65a8e2..c84925c57b 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -211,6 +211,7 @@ mymain(void)
     DO_TEST("cputopology");
     DO_TEST_FAILURE("cputopology-nvcpu-mismatch");
     DO_TEST("commandline");
+    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..7c8594fed8
--- /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 unknown='ignore'/>
+  </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 ed421b8839..e8a6867fcd 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -111,6 +111,7 @@ mymain(void)
     DO_TEST_DIFFERENT("vnc-vgaconf-io");
     DO_TEST_DIFFERENT("vnc-autoport");
     DO_TEST_DIFFERENT("commandline");
+    DO_TEST_DIFFERENT("msrs");
 
     /* Address allocation tests */
     DO_TEST_DIFFERENT("addr-single-sata-disk");
-- 
2.20.1




More information about the libvir-list mailing list