Re: [PATCH] qemu: Ensure the cpuset is formated as expected before passing to cgroup

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

 



On 2012年08月16日 13:06, Eric Blake wrote:
On 08/15/2012 09:35 PM, Osier Yang wrote:
The parameter value for cpuset could be in special format like
"0-10,^7", which is not recongnized by cgroup. This patch is to

s/recongnized/recognized/

ensure the cpuset is formated as expected before passing it to

s/formated/formatted/

cgroup. As a side effect, after the patch, it parses the cpuset
early before cgroup setting, to avoid the rollback if cpuset
parsing fails afterwards.
---
  src/qemu/qemu_driver.c |   77 +++++++++++++++++++++++++----------------------
  1 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 369e8ed..fc412a1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6952,8 +6952,23 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
              }
          } else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) {
              int rc;
-            bool savedmask;
-            char oldnodemask[VIR_DOMAIN_CPUMASK_LEN];
+            char *nodeset = NULL;
+            char *nodeset_str = NULL;
+
+            if (VIR_ALLOC_N(nodeset, VIR_DOMAIN_CPUMASK_LEN)<  0) {
+                virReportOOMError();
+                ret = -1;
+                goto cleanup;
+            };
+
+            if (virDomainCpuSetParse(params[i].value.s,
+                                     0, nodeset,
+                                     VIR_DOMAIN_CPUMASK_LEN)<  0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("Failed to parse nodeset"));
+                ret = -1;
+                continue;
+            }

We have enough of this open-coded conversions in the code base that it
would be worth common helper routines to make the conversion much easier
to use in the clients (for a later patch).  But for the purposes of
fixing the bug at hand, your patch does the trick.


              if (flags&  VIR_DOMAIN_AFFECT_LIVE) {
                  if (vm->def->numatune.memory.mode !=
@@ -6961,72 +6976,62 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
                      virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                                     _("change of nodeset for running domain "
                                       "requires strict numa mode"));
+                    VIR_FREE(nodeset);
                      ret = -1;
                      continue;
                  }
-                rc = virCgroupSetCpusetMems(group, params[i].value.s);
-                if (rc != 0) {
+
+                /* Ensure the cpuset string is formated before passing to cgroup */

s/formated/formatted/

hum, you corrected my typos on "recongnized" and "formated" several
times. /shy.


ACK with nits fixed.

Thanks, pushed with the nits fixed.

Regards,
Osier

--
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]