]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: add support for hv_crash feature as a panic device
authorDmitry Andreev <dandreev@virtuozzo.com>
Tue, 24 Nov 2015 12:26:33 +0000 (15:26 +0300)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 25 Nov 2015 13:46:20 +0000 (14:46 +0100)
Panic device type used depends on 'model' attribute.

If no model is specified then device type depends on hypervisor
and guest arch. 'pseries' model is used for pSeries guest and
'isa' model is used in other cases.

XML:
<devices>
  <panic model='hyperv'/>
</devices>

QEMU command line:
qemu -cpu <cpu_model>,hv_crash

12 files changed:
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuargv2xmltest.c
tests/qemuxml2argvdata/qemuxml2argv-hyperv-panic.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-panic-no-address.xml
tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.xml
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-panic.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index 4d00fd963d4527f7f14d84849d464837c8b64ba7..e83be585e9b1b3d1400965d6e2417900739ab598 100644 (file)
@@ -7577,6 +7577,16 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
         }
     }
 
+    if (def->panic &&
+        def->panic->model == VIR_DOMAIN_PANIC_MODEL_HYPERV) {
+        if (!have_cpu) {
+            virBufferAdd(&buf, default_model, -1);
+            have_cpu = true;
+        }
+
+        virBufferAddLit(&buf, ",hv_crash");
+    }
+
     if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) {
         if (!have_cpu) {
             virBufferAdd(&buf, default_model, -1);
@@ -11050,17 +11060,45 @@ qemuBuildCommandLine(virConnectPtr conn,
     }
 
     if (def->panic) {
-        if (ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine, "pseries")) {
+        switch ((virDomainPanicModel) def->panic->model) {
+        case VIR_DOMAIN_PANIC_MODEL_HYPERV:
+            /* Panic with model 'hyperv' is not a device, it should
+             * be configured in cpu commandline. The address
+             * cannot be configured by the user */
+            if (!ARCH_IS_X86(def->os.arch)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("only i686 and x86_64 guests support "
+                                 "panic device of model 'hyperv'"));
+                goto error;
+            }
+            if (def->panic->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("setting the panic device address is not "
+                                 "supported for model 'hyperv'"));
+                goto error;
+            }
+            break;
+
+        case VIR_DOMAIN_PANIC_MODEL_PSERIES:
             /* For pSeries guests, the firmware provides the same
              * functionality as the pvpanic device. The address
              * cannot be configured by the user */
+            if (!ARCH_IS_PPC64(def->os.arch) ||
+                !STRPREFIX(def->os.machine, "pseries")) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("only pSeries guests support panic device "
+                                 "of model 'pseries'"));
+                goto error;
+            }
             if (def->panic->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("setting the panic device address is not "
-                                 "supported for pSeries guests"));
+                                 "supported for model 'pseries'"));
                 goto error;
             }
-        } else {
+            break;
+
+        case VIR_DOMAIN_PANIC_MODEL_ISA:
             if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PANIC)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("the QEMU binary does not support the "
@@ -11085,6 +11123,11 @@ qemuBuildCommandLine(virConnectPtr conn,
                                  "with ISA address type"));
                 goto error;
             }
+
+        /* default model value was changed before in post parse */
+        case VIR_DOMAIN_PANIC_MODEL_DEFAULT:
+        case VIR_DOMAIN_PANIC_MODEL_LAST:
+            break;
         }
     }
 
@@ -12436,6 +12479,13 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
                 if (virCPUDefAddFeature(cpu, feature, policy) < 0)
                     goto cleanup;
             }
+        } else if (STREQ(tokens[i], "hv_crash")) {
+            virDomainPanicDefPtr panic;
+            if (VIR_ALLOC(panic) < 0)
+                goto cleanup;
+
+            panic->model = VIR_DOMAIN_PANIC_MODEL_HYPERV;
+            dom->panic = panic;
         } else if (STRPREFIX(tokens[i], "hv_")) {
             const char *token = tokens[i] + 3; /* "hv_" */
             const char *feature, *value;
index 18513f9bb4f59846647cc57342595956df333e13..689abc2830ce768051ec9b6b479b60497ecf12ae 100644 (file)
@@ -1350,6 +1350,15 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         }
     }
 
+    if (dev->type == VIR_DOMAIN_DEVICE_PANIC &&
+        dev->data.panic->model == VIR_DOMAIN_PANIC_MODEL_DEFAULT) {
+        if (ARCH_IS_PPC64(def->os.arch) &&
+            STRPREFIX(def->os.machine, "pseries"))
+            dev->data.panic->model = VIR_DOMAIN_PANIC_MODEL_PSERIES;
+        else
+            dev->data.panic->model = VIR_DOMAIN_PANIC_MODEL_ISA;
+    }
+
     ret = 0;
 
  cleanup:
index 34f3e5c111fede9ad018eb07ff51f454c2238e8e..7759a09488cb5647c49fd93af3ff642ab7dc61ed 100644 (file)
@@ -261,6 +261,7 @@ mymain(void)
     DO_TEST("smp");
 
     DO_TEST("hyperv");
+    DO_TEST("hyperv-panic");
 
     DO_TEST("kvm-features");
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv-panic.args b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-panic.args
new file mode 100644 (file)
index 0000000..a9f13e0
--- /dev/null
@@ -0,0 +1,21 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-cpu qemu32,hv_crash \
+-m 214 \
+-smp 6 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-boot n \
+-usb \
+-net none \
+-serial none \
+-parallel none
index 79f8a1e150456809b47554c111dabef1921c9351..f3f3fbb3af251c6ececcf6d9a5146a05a5d5df88 100644 (file)
@@ -24,6 +24,6 @@
     <controller type='ide' index='0'/>
     <controller type='pci' index='0' model='pci-root'/>
     <memballoon model='virtio'/>
-    <panic/>
+    <panic model='isa'/>
   </devices>
 </domain>
index 3a962098034019985ffd55bbdb127041252024c0..39f4a1f7265719974738fea92b4ff22f40e0af02 100644 (file)
@@ -37,6 +37,6 @@
       <model type='cirrus' vram='16384' heads='1'/>
     </video>
     <memballoon model='none'/>
-    <panic/>
+    <panic model='pseries'/>
   </devices>
 </domain>
index 619186a526bc6ef4b9e4b8b1b283a621ce0cee82..2da28323d8fade45308f2a0ed014d4507efd31cd 100644 (file)
@@ -20,6 +20,6 @@
     <nvram>
       <address type='spapr-vio' reg='0x4000'/>
     </nvram>
-    <panic/>
+    <panic model='pseries'/>
   </devices>
 </domain>
index dc8654ed705113e791fe092bb02b3ddfe3305658..a15305d2a5b5f9473054a688cfb32f6594957087 100644 (file)
@@ -692,6 +692,7 @@ mymain(void)
 
     DO_TEST("hyperv", NONE);
     DO_TEST("hyperv-off", NONE);
+    DO_TEST("hyperv-panic", NONE);
 
     DO_TEST("kvm-features", NONE);
     DO_TEST("kvm-features-off", NONE);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic.xml
new file mode 100644 (file)
index 0000000..b9595a8
--- /dev/null
@@ -0,0 +1,31 @@
+<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</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'/>
+    <controller type='fdc' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+    <panic model='isa'>
+      <address type='isa' iobase='0x505'/>
+    </panic>
+  </devices>
+</domain>
index 93129758002c99b2fa56952bf64749aa377dad2c..8fcd644a7713ef817cd7a5085472b06d7083da96 100644 (file)
@@ -25,6 +25,6 @@
       <address type='spapr-vio'/>
     </console>
     <memballoon model='none'/>
-    <panic/>
+    <panic model='pseries'/>
   </devices>
 </domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
new file mode 100644 (file)
index 0000000..8fcd644
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>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-ppc64</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <serial type='pty'>
+      <target port='0'/>
+      <address type='spapr-vio'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+      <address type='spapr-vio'/>
+    </console>
+    <memballoon model='none'/>
+    <panic model='pseries'/>
+  </devices>
+</domain>
index fbb46d608969ca2bed5130224eb2d2ed64f287d2..0e43ee92de27155c5cb2c95ce4e45754147caa7c 100644 (file)
@@ -535,7 +535,7 @@ mymain(void)
 
     DO_TEST("pseries-nvram");
     DO_TEST_DIFFERENT("pseries-panic-missing");
-    DO_TEST("pseries-panic-no-address");
+    DO_TEST_DIFFERENT("pseries-panic-no-address");
 
     /* These tests generate different XML */
     DO_TEST_DIFFERENT("balloon-device-auto");
@@ -591,7 +591,7 @@ mymain(void)
     DO_TEST("pcihole64-none");
     DO_TEST("pcihole64-q35");
 
-    DO_TEST("panic");
+    DO_TEST_DIFFERENT("panic");
     DO_TEST("panic-isa");
     DO_TEST("panic-pseries");
     DO_TEST("panic-no-address");