|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation
This patch allows an HVM domain to be created with multiple serial
ports.
Since the previous interface only allowed the passing of a single
device, this requires us to add a new element to the hvm struct of
libxl_domain_build_info -- serial_list. For API compatibility, the
old element, serial, remains.
If hvm.serial_list is set, each device listed will cause an extra
"-serial [foo]" to be appended to the qemu command line.
Callers may set either hvm.serial or hvm.serial_list, but not
both; libxl will throw an error if both are set.
In order to allow users of libxl to write software compatible with
older versions of libxl, also define LIBXL_HAVE_BUILDINFO_SERIAL_LIST.
If this is defined, callers may use either hvm.serial or
hvm.serial_list; otherwise, only hvm.serial will be available.
This patch borrows substantially from the multiple USB device patch
ac16730d0339d41fd7d129a5cb2d40ed67a303d9.
Signed-off-by: Ed White <edmund.h.white@xxxxxxxxx>
---
tools/libxl/libxl.h | 16 ++++++++++++++++
tools/libxl/libxl_dm.c | 44 ++++++++++++++++++++++++++++++++++++++++----
tools/libxl/libxl_types.idl | 1 +
3 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 5ae6532..3f6cc4a 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -579,6 +579,22 @@ typedef struct libxl__ctx libxl_ctx;
*/
#define LIBXL_HAVE_CPUPOOL_NAME 1
+/*
+ * LIBXL_HAVE_BUILDINFO_SERIAL_LIST
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain hvm.serial_list, a libxl_string_list type that contains
+ * a list of serial ports to specify on the qemu command-line.
+ *
+ * If it is set, callers may use either hvm.serial or
+ * hvm.serial_list, but not both; if both are set, libxl will
+ * throw an error.
+ *
+ * If this is not defined, callers can only use hvm.serial. Note
+ * that this means only one serial port can be added at domain build time.
+ */
+#define LIBXL_HAVE_BUILDINFO_SERIAL_LIST 1
+
typedef uint8_t libxl_mac[6];
#define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
#define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index addacdb..0b83ed9 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -196,8 +196,26 @@ static char **
libxl__build_device_model_args_old(libxl__gc *gc,
int nr_set_cpus = 0;
char *s;
- if (b_info->u.hvm.serial) {
- flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
+ if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
+ if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
+ {
+ LOG(ERROR, "%s: Both serial and serial_list set",
+ __func__);
+ return NULL;
+ }
+ if (b_info->u.hvm.serial) {
+ flexarray_vappend(dm_args,
+ "-serial", b_info->u.hvm.serial, NULL);
+ } else if (b_info->u.hvm.serial_list) {
+ char **p;
+ for (p = b_info->u.hvm.serial_list;
+ *p;
+ p++) {
+ flexarray_vappend(dm_args,
+ "-serial",
+ *p, NULL);
+ }
+ }
}
if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
@@ -479,8 +497,26 @@ static char **
libxl__build_device_model_args_new(libxl__gc *gc,
if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
int ioemu_nics = 0;
- if (b_info->u.hvm.serial) {
- flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
+ if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
+ if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
+ {
+ LOG(ERROR, "%s: Both serial and serial_list set",
+ __func__);
+ return NULL;
+ }
+ if (b_info->u.hvm.serial) {
+ flexarray_vappend(dm_args,
+ "-serial", b_info->u.hvm.serial, NULL);
+ } else if (b_info->u.hvm.serial_list) {
+ char **p;
+ for (p = b_info->u.hvm.serial_list;
+ *p;
+ p++) {
+ flexarray_vappend(dm_args,
+ "-serial",
+ *p, NULL);
+ }
+ }
}
if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index a412f9c..1e56b34 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -395,6 +395,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
("vendor_device",
libxl_vendor_device),
# See libxl_ms_vm_genid_generate()
("ms_vm_genid", libxl_ms_vm_genid),
+ ("serial_list", libxl_string_list),
])),
("pv", Struct(None, [("kernel", string),
("slack_memkb", MemKB),
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |