[PATCH] Add support for disabling S3 and S4 states

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

 



There a two new elements in <features> implemented, which control what
ACPI sleeping states will be advertised. The default is to have both
states enabled, so this means no change for current machines.
---
 docs/schemas/domaincommon.rng                      |   10 ++++++
 src/conf/domain_conf.c                             |    4 ++-
 src/conf/domain_conf.h                             |    2 +
 src/qemu/qemu_command.c                            |   17 +++++++++++
 src/qemu/qemu_driver.c                             |   15 ++++++++++
 tests/qemuargv2xmltest.c                           |    3 ++
 .../qemuxml2argv-misc-disable-s3.args              |    4 ++
 .../qemuxml2argv-misc-disable-s3.xml               |   29 +++++++++++++++++++
 .../qemuxml2argv-misc-disable-s4.args              |    4 ++
 .../qemuxml2argv-misc-disable-s4.xml               |   29 +++++++++++++++++++
 .../qemuxml2argv-misc-disable-suspends.args        |    4 ++
 .../qemuxml2argv-misc-disable-suspends.xml         |   30 ++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |    3 ++
 tests/qemuxml2xmltest.c                            |    3 ++
 14 files changed, 156 insertions(+), 1 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index b7562ad..859cb26 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2788,6 +2788,16 @@
               <empty/>
             </element>
           </optional>
+          <optional>
+            <element name="disable_s3">
+              <empty/>
+            </element>
+          </optional>
+          <optional>
+            <element name="disable_s4">
+              <empty/>
+            </element>
+          </optional>
         </interleave>
       </element>
     </optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 143d92e..1bfb8d0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -107,7 +107,9 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
               "pae",
               "hap",
               "viridian",
-              "privnet")
+              "privnet",
+              "disable_s3",
+              "disable_s4")

 VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST,
               "destroy",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bc02caf..b7ee95e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1346,6 +1346,8 @@ enum virDomainFeature {
     VIR_DOMAIN_FEATURE_HAP,
     VIR_DOMAIN_FEATURE_VIRIDIAN,
     VIR_DOMAIN_FEATURE_PRIVNET,
+    VIR_DOMAIN_FEATURE_DISABLE_S3,
+    VIR_DOMAIN_FEATURE_DISABLE_S4,

     VIR_DOMAIN_FEATURE_LAST
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4033644..ee9e169 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4691,6 +4691,12 @@ qemuBuildCommandLine(virConnectPtr conn,
             virCommandAddArg(cmd, "-no-acpi");
     }

+    if (def->features & (1 << VIR_DOMAIN_FEATURE_DISABLE_S3))
+        virCommandAddArgList(cmd, "-global", "PIIX4_PM.disable_s3=1", NULL);
+
+    if (def->features & (1 << VIR_DOMAIN_FEATURE_DISABLE_S4))
+        virCommandAddArgList(cmd, "-global", "PIIX4_PM.disable_s4=1", NULL);
+
     if (!def->os.bootloader) {
         /*
          * We prefer using explicit bootindex=N parameters for predictable
@@ -8191,6 +8197,17 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,

                 *monConfig = chr;
             }
+        } else if (STREQ(arg, "-global") &&
+                   STREQ(progargv[i + 1], "PIIX4_PM.disable_s3=1")) {
+            /* We want to parse only the known "-global" parameters,
+             * so the ones that we don't know are still added to the
+             * namespace */
+            i++;
+            def->features |= (1 << VIR_DOMAIN_FEATURE_DISABLE_S3);
+        } else if (STREQ(arg, "-global") &&
+                   STREQ(progargv[i + 1], "PIIX4_PM.disable_s4=1")) {
+            i++;
+            def->features |= (1 << VIR_DOMAIN_FEATURE_DISABLE_S4);
         } else if (STREQ(arg, "-S")) {
             /* ignore, always added by libvirt */
         } else {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0da5c5a..76dd374 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13060,6 +13060,21 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
         goto cleanup;
     }

+    if (vm->def->features & (1 << VIR_DOMAIN_FEATURE_DISABLE_S3) &&
+        (target == VIR_NODE_SUSPEND_TARGET_MEM ||
+         target == VIR_NODE_SUSPEND_TARGET_HYBRID)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("S3 signals are disabled for this domain"));
+        goto cleanup;
+    }
+
+    if (vm->def->features & (1 << VIR_DOMAIN_FEATURE_DISABLE_S4) &&
+        target == VIR_NODE_SUSPEND_TARGET_DISK) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("S4 signals are disabled for this domain"));
+        goto cleanup;
+    }
+
     if (priv->agentError) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("QEMU guest agent is not available due to an error"));
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 439218e..7fae39a 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -205,6 +205,9 @@ mymain(void)
     /* Can't rountrip xenner arch */
     /*DO_TEST("input-xen");*/
     DO_TEST("misc-acpi");
+    DO_TEST("misc-disable-s3");
+    DO_TEST("misc-disable-s4");
+    DO_TEST("misc-disable-suspends");
     DO_TEST("misc-no-reboot");
     DO_TEST("misc-uuid");
     DO_TEST("net-user");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
new file mode 100644
index 0000000..dbee64d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S \
+-M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -global PIIX4_PM.disable_s3=1 -boot c -hda /dev/HostVG/QEMUGuest1 \
+-net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
new file mode 100644
index 0000000..4b2d13e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
@@ -0,0 +1,29 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>8caaa98c-e7bf-5845-126a-1fc316bd1089</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <disable_s3/>
+  </features>
+  <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='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.args
new file mode 100644
index 0000000..9177904
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S \
+-M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -global PIIX4_PM.disable_s4=1 -boot c -hda /dev/HostVG/QEMUGuest1 \
+-net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.xml
new file mode 100644
index 0000000..1a27e9f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s4.xml
@@ -0,0 +1,29 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>8caaa98c-e7bf-5845-126a-1fc316bd1089</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <disable_s4/>
+  </features>
+  <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='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
new file mode 100644
index 0000000..6f63d8b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S \
+-M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot c \
+-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
new file mode 100644
index 0000000..587e80a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>8caaa98c-e7bf-5845-126a-1fc316bd1089</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <disable_s3/>
+    <disable_s4/>
+  </features>
+  <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='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c4aa7c4..c7a3d50 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -561,6 +561,9 @@ mymain(void)
     DO_TEST("input-usbtablet", NONE);
     DO_TEST_ERROR("input-xen", QEMU_CAPS_DOMID);
     DO_TEST("misc-acpi", NONE);
+    DO_TEST("misc-disable-s3", NONE);
+    DO_TEST("misc-disable-s4", NONE);
+    DO_TEST("misc-disable-suspends", NONE);
     DO_TEST("misc-no-reboot", NONE);
     DO_TEST("misc-uuid", QEMU_CAPS_NAME, QEMU_CAPS_UUID);
     DO_TEST("net-user", NONE);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index dcdba4f..f7622b7 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -170,6 +170,9 @@ mymain(void)
     DO_TEST("input-usbtablet");
     DO_TEST("input-xen");
     DO_TEST("misc-acpi");
+    DO_TEST("misc-disable-s3");
+    DO_TEST("misc-disable-s4");
+    DO_TEST("misc-disable-suspends");
     DO_TEST("misc-no-reboot");
     DO_TEST("net-user");
     DO_TEST("net-virtio");
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]