[Libguestfs] [PATCH] set-smp: only set smp value at config time

Wanlong Gao gaowanlong at cn.fujitsu.com
Wed Feb 22 14:33:59 UTC 2012


We only set smp number at config time, other than
it has no effect.
Also limit the number value below 255, since qemu
can't support that.

Below is the reproduce from https://bugzilla.redhat.com/show_bug.cgi?id=795322

> # guestfish -a /dev/null
> [...]
> ><fs> run
> ><fs> get-smp
> 1
> ><fs> set-smp 4
> ><fs> get-smp
> 4
> ><fs>
>
> Actually, we're expecting to get 1 rather than 4, because there is only one
> vcpu assigned to the appliance, and it's impossible for the appliance to get 4
> virtual vcpus now.

Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
---
 src/guestfs.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/guestfs.c b/src/guestfs.c
index 3607eaa..3dcdf27 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -794,7 +794,12 @@ guestfs__get_pgroup (guestfs_h *g)
 int
 guestfs__set_smp (guestfs_h *g, int v)
 {
-  if (v >= 1) {
+  if (g->state != CONFIG)
+    return 0;
+  if (v > 255) {
+    error (g, "Unsupported number of smp cpus: %d", v);
+    return -1;
+  } else if (v >= 1) {
     g->smp = v;
     return 0;
   } else {
-- 
1.7.9




More information about the Libguestfs mailing list