summaryrefslogtreecommitdiffstats
path: root/qemu/hw/xenpv
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/hw/xenpv')
-rw-r--r--qemu/hw/xenpv/Makefile.objs4
-rw-r--r--qemu/hw/xenpv/xen_domainbuild.c13
-rw-r--r--qemu/hw/xenpv/xen_machine_pv.c33
3 files changed, 29 insertions, 21 deletions
diff --git a/qemu/hw/xenpv/Makefile.objs b/qemu/hw/xenpv/Makefile.objs
index 49f6e9e3c..bbf5873fd 100644
--- a/qemu/hw/xenpv/Makefile.objs
+++ b/qemu/hw/xenpv/Makefile.objs
@@ -1,2 +1,4 @@
# Xen PV machine support
-obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
+obj-$(CONFIG_XEN) += xen_machine_pv.o
+# Xen PV machine builder support
+obj-$(CONFIG_XEN_PV_DOMAIN_BUILD) += xen_domainbuild.o
diff --git a/qemu/hw/xenpv/xen_domainbuild.c b/qemu/hw/xenpv/xen_domainbuild.c
index c0ab7537d..5a9f5ac80 100644
--- a/qemu/hw/xenpv/xen_domainbuild.c
+++ b/qemu/hw/xenpv/xen_domainbuild.c
@@ -1,4 +1,4 @@
-#include <signal.h>
+#include "qemu/osdep.h"
#include "hw/xen/xen_backend.h"
#include "xen_domainbuild.h"
#include "qemu/timer.h"
@@ -174,12 +174,15 @@ static int xen_domain_watcher(void)
for (i = 3; i < n; i++) {
if (i == fd[0])
continue;
- if (i == xc_fd(xen_xc)) {
- continue;
- }
close(i);
}
+ /*
+ * Reopen xc interface, since the original is unsafe after fork
+ * and was closed above.
+ */
+ xen_xc = xc_interface_open(0, 0, 0);
+
/* ignore term signals */
signal(SIGINT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
@@ -234,7 +237,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
int rc;
memcpy(uuid, qemu_uuid, sizeof(uuid));
- rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+ rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
if (rc < 0) {
fprintf(stderr, "xen: xc_domain_create() failed\n");
goto err;
diff --git a/qemu/hw/xenpv/xen_machine_pv.c b/qemu/hw/xenpv/xen_machine_pv.c
index 2e545d241..fc1353599 100644
--- a/qemu/hw/xenpv/xen_machine_pv.c
+++ b/qemu/hw/xenpv/xen_machine_pv.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/boards.h"
#include "hw/xen/xen_backend.h"
@@ -30,9 +31,6 @@
static void xen_init_pv(MachineState *machine)
{
- const char *kernel_filename = machine->kernel_filename;
- const char *kernel_cmdline = machine->kernel_cmdline;
- const char *initrd_filename = machine->initrd_filename;
DriveInfo *dinfo;
int i;
@@ -46,17 +44,27 @@ static void xen_init_pv(MachineState *machine)
case XEN_ATTACH:
/* nothing to do, xend handles everything */
break;
- case XEN_CREATE:
+#ifdef CONFIG_XEN_PV_DOMAIN_BUILD
+ case XEN_CREATE: {
+ const char *kernel_filename = machine->kernel_filename;
+ const char *kernel_cmdline = machine->kernel_cmdline;
+ const char *initrd_filename = machine->initrd_filename;
if (xen_domain_build_pv(kernel_filename, initrd_filename,
kernel_cmdline) < 0) {
fprintf(stderr, "xen pv domain creation failed\n");
exit(1);
}
break;
+ }
+#endif
case XEN_EMULATE:
fprintf(stderr, "xen emulation not implemented (yet)\n");
exit(1);
break;
+ default:
+ fprintf(stderr, "unhandled xen_mode %d\n", xen_mode);
+ exit(1);
+ break;
}
xen_be_register("console", &xen_console_ops);
@@ -93,17 +101,12 @@ static void xen_init_pv(MachineState *machine)
xen_init_display(xen_domid);
}
-static QEMUMachine xenpv_machine = {
- .name = "xenpv",
- .desc = "Xen Para-virtualized PC",
- .init = xen_init_pv,
- .max_cpus = 1,
- .default_machine_opts = "accel=xen",
-};
-
-static void xenpv_machine_init(void)
+static void xenpv_machine_init(MachineClass *mc)
{
- qemu_register_machine(&xenpv_machine);
+ mc->desc = "Xen Para-virtualized PC";
+ mc->init = xen_init_pv;
+ mc->max_cpus = 1;
+ mc->default_machine_opts = "accel=xen";
}
-machine_init(xenpv_machine_init);
+DEFINE_MACHINE("xenpv", xenpv_machine_init)