[PATCH] set-smp: only set smp value at config time
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@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
There are some problems with this patch, but mainly see my comments on this bug: https://bugzilla.redhat.com/show_bug.cgi?id=796520 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
On 02/23/2012 04:45 PM, Richard W.M. Jones wrote:
There are some problems with this patch, but mainly see my comments on this bug:
Rich: Did you mean adding a ConfigOnly flag to each non-daemon-function? Thanks -Wanlong Gao
Rich.
On Thu, Feb 23, 2012 at 05:15:24PM +0800, Wanlong Gao wrote:
On 02/23/2012 04:45 PM, Richard W.M. Jones wrote:
There are some problems with this patch, but mainly see my comments on this bug:
Rich:
Did you mean adding a ConfigOnly flag to each non-daemon-function?
Yes, to all the ones in the first list: https://bugzilla.redhat.com/show_bug.cgi?id=796520#c2 so eg: - ("add_cdrom", (RErr, [String "filename"], []), -1, [DeprecatedBy "add_drive_opts"], + ("add_cdrom", (RErr, [String "filename"], []), -1, [DeprecatedBy "add_drive_opts"; ConfigOnly], and then of course the generator has to be changed. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
On 02/23/2012 05:34 PM, Richard W.M. Jones wrote:
On Thu, Feb 23, 2012 at 05:15:24PM +0800, Wanlong Gao wrote:
On 02/23/2012 04:45 PM, Richard W.M. Jones wrote:
There are some problems with this patch, but mainly see my comments on this bug:
Rich:
Did you mean adding a ConfigOnly flag to each non-daemon-function?
Yes, to all the ones in the first list:
https://bugzilla.redhat.com/show_bug.cgi?id=796520#c2
so eg:
- ("add_cdrom", (RErr, [String "filename"], []), -1, [DeprecatedBy "add_drive_opts"], + ("add_cdrom", (RErr, [String "filename"], []), -1, [DeprecatedBy "add_drive_opts"; ConfigOnly],
and then of course the generator has to be changed.
Yes, I see, thank you.
Rich.
participants (2)
-
Richard W.M. Jones -
Wanlong Gao