commit 01626771cf2e9285fbfddcbded2820fc77745e4b
Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Date: Fri Apr 30 17:41:45 2010 +0100
Implement 'xm vcpu-set' command for HVM guest
Currently Xen has 'xm vcpu-set' command for PV domain, but not
available for HVM domain. This patch is use to enable 'xm vcpu-set'
command for HVM domain. It setup vcpu watch at xenstore, and at qemu
side, handle vcpu online/offline accordingly. With this patch, 'xm
vcpu-set' command works for both PV and HVM guest with same format.
Signed-off-by: Liu, Jinsong <jinsong.liu@xxxxxxxxx>
---
hw/piix4acpi.c | 5 +++--
xenstore.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c
index 3c52c4b..1efa77d 100644
--- a/hw/piix4acpi.c
+++ b/hw/piix4acpi.c
@@ -749,8 +749,8 @@ static int disable_processor(GPEState *g, int cpu)
void qemu_cpu_add_remove(int cpu, int state)
{
- if ((cpu <=0) || (cpu >= vcpus)) {
- fprintf(stderr, "vcpu out of range, should be [1~%d]\n", vcpus - 1);
+ if ((cpu <0) || (cpu >= vcpus)) {
+ fprintf(stderr, "vcpu out of range, should be [0~%d]\n", vcpus - 1);
return;
}
@@ -761,6 +761,7 @@ void qemu_cpu_add_remove(int cpu, int state)
if (!disable_processor(&gpe_state, cpu))
return;
}
+ fprintf(logfile, "%s vcpu %d\n", state ? "Add" : "Remove", cpu);
if (gpe_state.gpe0_en[0] & 4) {
qemu_set_irq(sci_irq, 1);
diff --git a/xenstore.c b/xenstore.c
index 89b1938..43d30ee 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -657,6 +657,12 @@ void xenstore_parse_domain_config(int hvm_domid)
fprintf(logfile, "Watching %s\n", buf);
}
+ /* Set a watch for vcpu-set */
+ if (pasprintf(&buf, "/local/domain/%u/cpu", domid) != -1) {
+ xs_watch(xsh, buf, "vcpu-set");
+ fprintf(logfile, "Watching %s\n", buf);
+ }
+
/* no need for ifdef CONFIG_STUBDOM, since in the qemu case
* hvm_domid is always equal to domid */
hvm_domid = domid;
@@ -938,6 +944,36 @@ void xenstore_record_dm_state(const char *state)
xenstore_record_dm("state", state);
}
+static void xenstore_process_vcpu_set_event(char **vec)
+{
+ char *act = NULL;
+ char *vcpustr, *node = vec[XS_WATCH_PATH];
+ unsigned int vcpu, len;
+
+ vcpustr = strstr(node, "cpu/");
+ if (!vcpustr) {
+ fprintf(stderr, "vcpu-set: watch node error.\n");
+ return;
+ }
+ sscanf(vcpustr, "cpu/%u", &vcpu);
+
+ act = xs_read(xsh, XBT_NULL, node, &len);
+ if (!act) {
+ fprintf(stderr, "vcpu-set: no command yet.\n");
+ return;
+ }
+
+ if (!strncmp(act, "online", len))
+ qemu_cpu_add_remove(vcpu, 1);
+ else if (!strncmp(act, "offline", len))
+ qemu_cpu_add_remove(vcpu, 0);
+ else
+ fprintf(stderr, "vcpu-set: command error.\n");
+
+ free(act);
+ return;
+}
+
void xenstore_process_event(void *opaque)
{
char **vec, *offset, *bpath = NULL, *buf = NULL, *drv = NULL, *image =
NULL;
@@ -958,6 +994,11 @@ void xenstore_process_event(void *opaque)
goto out;
}
+ if (!strcmp(vec[XS_WATCH_TOKEN], "vcpu-set")) {
+ xenstore_process_vcpu_set_event(vec);
+ goto out;
+ }
+
/* if we are paused don't process anything else */
if (xen_pause_requested)
goto out;
--
generated by git-patchbot for /home/xen/git/qemu-xen-unstable.git
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|