summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-09-28 14:39:31 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-09-28 14:52:56 +0100
commit04fbcc63ebf5718608f199eb6b09061cd32283c3 (patch)
tree1df1bb78ce7df4f9363ca8ca41e567026aea2d8a /src
parent8403f5a9d8f1451e2c2b029b51bac18724b18ebf (diff)
downloadlibguestfs-04fbcc63ebf5718608f199eb6b09061cd32283c3.tar.gz
libguestfs-04fbcc63ebf5718608f199eb6b09061cd32283c3.tar.xz
libguestfs-04fbcc63ebf5718608f199eb6b09061cd32283c3.zip
New API: set-smp, get-smp
These calls allow you to change the number of virtual CPUs assigned to the appliance. This also adds a --smp option to virt-rescue.
Diffstat (limited to 'src')
-rw-r--r--src/guestfs-internal.h2
-rw-r--r--src/guestfs.c21
-rw-r--r--src/launch.c6
3 files changed, 29 insertions, 0 deletions
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index c0a2be48..494003ef 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -170,6 +170,8 @@ struct guestfs_h
int pgroup; /* Create process group for children? */
+ int smp; /* If > 1, -smp flag passed to qemu. */
+
char *last_error;
int last_errnum; /* errno, or 0 if there was no errno */
diff --git a/src/guestfs.c b/src/guestfs.c
index 002418a4..f7ad9674 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -144,6 +144,9 @@ guestfs_create (void)
*/
g->msg_next_serial = 0x00123400;
+ /* Default is uniprocessor appliance. */
+ g->smp = 1;
+
/* Link the handles onto a global list. */
gl_lock_lock (handles_lock);
g->next = handles;
@@ -814,6 +817,24 @@ guestfs__get_pgroup (guestfs_h *g)
return g->pgroup;
}
+int
+guestfs__set_smp (guestfs_h *g, int v)
+{
+ if (v >= 1) {
+ g->smp = v;
+ return 0;
+ } else {
+ error (g, "invalid smp parameter: %d", v);
+ return -1;
+ }
+}
+
+int
+guestfs__get_smp (guestfs_h *g)
+{
+ return g->smp;
+}
+
/* Note the private data area is allocated lazily, since the vast
* majority of callers will never use it. This means g->pda is
* likely to be NULL.
diff --git a/src/launch.c b/src/launch.c
index 80eadef2..b0f5b394 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -555,6 +555,12 @@ launch_appliance (guestfs_h *g)
add_cmdline (g, "-nographic");
+ if (g->smp > 1) {
+ snprintf (buf, sizeof buf, "%d", g->smp);
+ add_cmdline (g, "-smp");
+ add_cmdline (g, buf);
+ }
+
snprintf (buf, sizeof buf, "%d", g->memsize);
add_cmdline (g, "-m");
add_cmdline (g, buf);