]> xenbits.xensource.com Git - libvirt.git/commitdiff
bhyve: implement ignore unknown MSRs feature
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Fri, 25 Jan 2019 15:27:58 +0000 (19:27 +0400)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Sun, 24 Feb 2019 09:20:51 +0000 (13:20 +0400)
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@gmail.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
docs/formatdomain.html.in
src/bhyve/bhyve_command.c
tests/bhyvexml2argvdata/bhyvexml2argv-msrs.args [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-msrs.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-msrs.xml [new file with mode: 0644]
tests/bhyvexml2argvtest.c
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-msrs.xml [new file with mode: 0644]
tests/bhyvexml2xmltest.c

index 7882c54bc184ca08499566a05f05ed37edeaf0da..b848e535e6284a806f1fbbdc029d8d8eb009313f 100644 (file)
     &lt;tlbflush state='on'/&gt;
     &lt;ipi state='on'/&gt;
     &lt;evmcs state='on'/&gt;
+    &lt;msrs unknown='ignore'/&gt;
   &lt;/hyperv&gt;
   &lt;kvm&gt;
     &lt;hidden state='on'/&gt;
           defined, the hypervisor default will be used.
           <span class="since">Since 4.10.0</span> (QEMU/KVM only)
       </dd>
+      <dt><code>msrs</code></dt>
+      <dd>Some guests might require ignoring unknown
+          Model Specific Registers (MSRs) reads and writes. It's possible
+          to switch this by setting <code>unknown</code> attribute
+          of <code>msrs</code> to <code>ignore</code>. If the attribute is
+          not defined, or set to <code>fault</code>, unknown reads and writes
+          will not be ignored.
+          <span class="since">Since 5.1.0</span> (bhyve only)
+      </dd>
     </dl>
 
     <h3><a id="elementsTime">Time keeping</a></h3>
index 1f215dac085dd207e0733ecae746863f7b724f5a..52ad3e3714210f751ab2accbd88e6f67e5df4b6d 100644 (file)
@@ -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 (file)
index 0000000..dbe3774
--- /dev/null
@@ -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 (file)
index 0000000..32538b5
--- /dev/null
@@ -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 (file)
index 0000000..dc9de93
--- /dev/null
@@ -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>
index 4a7f65a8e21ae52676e301aa60b00908cefe09af..c84925c57bf2d864d92ebb62720e80f2f3b57254 100644 (file)
@@ -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 (file)
index 0000000..7c8594f
--- /dev/null
@@ -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>
index ed421b883931fc79f87c3570ddce995a6e7725dd..e8a6867fcd57a3026f89b2b0cfa44076bff8bc57 100644 (file)
@@ -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");