diff mbox

[RFC,v2,4/6] qemu: slave machine flag

Message ID 1458292438-13909-5-git-send-email-b.reynal@virtualopensystems.com (mailing list archive)
State New, archived
Headers show

Commit Message

Baptiste Reynal March 18, 2016, 9:13 a.m. UTC
From: Christian Pinto <c.pinto@virtualopensystems.com>

This patch adds a new machine flag, to configure qemu as a slave instance.

Usage

-machine -slave=[on|off] (default=off)

Signed-off-by: Christian Pinto <c.pinto@virtualopensystems.com>
---
 hw/core/machine.c   | 27 +++++++++++++++++++++++++++
 include/hw/boards.h |  2 ++
 qemu-options.hx     |  5 ++++-
 util/qemu-config.c  |  5 +++++
 4 files changed, 38 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/hw/core/machine.c b/hw/core/machine.c
index f4db340..b3e1e28 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -283,6 +283,20 @@  static bool machine_get_suppress_vmdesc(Object *obj, Error **errp)
     return ms->suppress_vmdesc;
 }
 
+static bool machine_get_slave(Object *obj, Error **errp)
+{
+    MachineState *ms = MACHINE(obj);
+
+    return ms->slave;
+}
+
+static void machine_set_slave(Object *obj, bool value, Error **errp)
+{
+    MachineState *ms = MACHINE(obj);
+
+    ms->slave = value;
+}
+
 static int error_on_sysbus_device(SysBusDevice *sbdev, void *opaque)
 {
     error_report("Option '-device %s' cannot be handled by this machine",
@@ -335,6 +349,7 @@  static void machine_initfn(Object *obj)
     ms->kvm_shadow_mem = -1;
     ms->dump_guest_core = true;
     ms->mem_merge = true;
+    ms->slave = false;
 
     object_property_add_str(obj, "accel",
                             machine_get_accel, machine_set_accel, NULL);
@@ -437,6 +452,13 @@  static void machine_initfn(Object *obj)
     object_property_set_description(obj, "suppress-vmdesc",
                                     "Set on to disable self-describing migration",
                                     NULL);
+    object_property_add_bool(obj, "slave",
+                             machine_get_slave,
+                             machine_set_slave,
+                             NULL);
+    object_property_set_description(obj, "slave",
+                                    "Enables a slave (remote) machine instance",
+                                    NULL);
 
     /* Register notifier when init is done for sysbus sanity checks */
     ms->sysbus_notifier.notify = machine_init_notify;
@@ -497,6 +519,11 @@  bool machine_mem_merge(MachineState *machine)
     return machine->mem_merge;
 }
 
+bool machine_slave(MachineState *machine)
+{
+    return machine->slave;
+}
+
 static const TypeInfo machine_info = {
     .name = TYPE_MACHINE,
     .parent = TYPE_OBJECT,
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3e9a92c..523cfc2 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -40,6 +40,7 @@  int machine_kvm_shadow_mem(MachineState *machine);
 int machine_phandle_start(MachineState *machine);
 bool machine_dump_guest_core(MachineState *machine);
 bool machine_mem_merge(MachineState *machine);
+bool machine_slave(MachineState *machine);
 
 /**
  * MachineClass:
@@ -120,6 +121,7 @@  struct MachineState {
     char *firmware;
     bool iommu;
     bool suppress_vmdesc;
+    bool slave;
 
     ram_addr_t ram_size;
     ram_addr_t maxram_size;
diff --git a/qemu-options.hx b/qemu-options.hx
index 7e147b8..96300ba 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -41,7 +41,8 @@  DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
     "                igd-passthru=on|off controls IGD GFX passthrough support (default=off)\n"
     "                aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n"
     "                dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n"
-    "                suppress-vmdesc=on|off disables self-describing migration (default=off)\n",
+    "                suppress-vmdesc=on|off disables self-describing migration (default=off)\n"
+    "                slave=on|off enables a slave (remote) machine instance (default=off)",
     QEMU_ARCH_ALL)
 STEXI
 @item -machine [type=]@var{name}[,prop=@var{value}[,...]]
@@ -80,6 +81,8 @@  execution of AES cryptographic functions.  The default is on.
 Enables or disables DEA key wrapping support on s390-ccw hosts. This feature
 controls whether DEA wrapping keys will be created to allow
 execution of DEA cryptographic functions.  The default is on.
+@item slave=on|off
+Enables a slave (remote) machine instance
 @end table
 ETEXI
 
diff --git a/util/qemu-config.c b/util/qemu-config.c
index 5fcfd0e..696408d 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -219,6 +219,11 @@  static QemuOptsList machine_opts = {
             .name = "suppress-vmdesc",
             .type = QEMU_OPT_BOOL,
             .help = "Set on to disable self-describing migration",
+        },{
+            .name = "slave",
+            .type = QEMU_OPT_BOOL,
+            .help = "Indicates the machine is a slave instance "
+                    "(e.g. remoteproc)",
         },
         { /* End of list */ }
     }