libxl: Some fixes related to Qemu upstream command lines.
cover libxl: Some fixes related to Qemu upstream command lines.
From: Anthony PERARD <[email protected]>
This series comes with some fixes for hvm guest with Qemu upstream, and completes the function libxl_build_device_model_args_new to make XenPV guest works with the Qemu upstream (when it's needed).
Anthony PERARD (5):
libxl: fix double free of ifname, when makes args for qemu.
libxl: strdup disk path before put it in qemu args array.
libxl: Specify the target ram size to Qemu (new) when calling it
libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
libxl: Lists qdisk device in libxl_device_disk_list
tools/libxl/libxl.c | 78 +++++++++++++++++++++++++++++++++++++--------- tools/libxl/libxl.idl | 1 + tools/libxl/xl_cmdimpl.c | 1 + 3 files changed, 65 insertions(+), 15 deletions(-)
Signature · 1 line
Anthony PERARD
PATCH 1/5 libxl: fix double free of ifname, when makes args for qemu.
From: Anthony PERARD <[email protected]>
In libxl_build_device_model_args_new, vifs[i].ifname can be free two times, by the gc, and by freeing the vifs structures. This patch avoids this.
--- tools/libxl/libxl.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
tools/libxl/libxl.c +7 -3
@@ -1341,14 +1341,18 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,char *smac =libxl__sprintf (gc,"%02x:%02x:%02x:%02x:%02x:%02x" , vifs[i].mac[0 ], vifs[i].mac[1 ], vifs[i].mac[2 ], vifs[i].mac[3 ], vifs[i].mac[4 ], vifs[i].mac[5 ]); -if (!vifs[i].ifname) - vifs[i].ifname =libxl__sprintf (gc,"tap%d.%d" , info->domid, vifs[i].devid); +char *ifname; +if (!vifs[i].ifname) { + ifname =libxl__sprintf (gc,"tap%d.%d" , info->domid, vifs[i].devid); + }else { + ifname = vifs[i].ifname; + }flexarray_set (dm_args, num++,"-net" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"nic,vlan=%d,macaddr=%s,model=%s" , vifs[i].devid, smac, vifs[i].model));flexarray_set (dm_args, num++,"-net" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"tap,vlan=%d,ifname=%s,script=no" , - vifs[i].devid, vifs[i].ifname)); + vifs[i].devid, ifname)); ioemu_vifs++; } }
Signature · 1 line
1.7.1
PATCH 2/5 libxl: strdup disk path before put it in qemu args array.
In reply to [email protected]From: Anthony PERARD <[email protected]>
In libxl_build_device_model_args_new, the path to the disk image are freeed before there was actually use to make the arguments list of Qemu. The patch strdups it.
--- tools/libxl/libxl.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +5 -5
@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (!dm_args)return NULL ; -flexarray_set (dm_args, num++,"qemu-system-xen" ); -flexarray_set (dm_args, num++,"-xen-domid" ); +flexarray_set (dm_args, num++,"qemu-dm" ); +flexarray_set (dm_args, num++,"-xen-domid" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->domid));if (info->dom_name) {
@@ -1378,10 +1378,10 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,for (i; i < nb; i++) {if ( disks[i].is_cdrom ) {flexarray_set (dm_args, num++,"-cdrom" ); -flexarray_set (dm_args, num++, disks[i].physpath); - }else { +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); + }else {flexarray_set (dm_args, num++,libxl__sprintf (gc,"-%s" , disks[i].virtpath)); -flexarray_set (dm_args, num++, disks[i].physpath); +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); }libxl_device_disk_destroy (&disks[i]); }
Signature · 1 line
1.7.1
Re: [PATCH 2/5] libxl: strdup disk path before put it in qemu args array.
Quoted 14 lines · On Thu, 2010-12-09 at 19:42 +0000, [email protected] wrote:
From: Anthony PERARD <[email protected]>
In
libxl_build_device_model_args_new, the path to the disk image are freeed before there was actually use to make the arguments list of Qemu. The patch strdups it.--- tools/libxl/libxl.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0
tools/libxl/libxl.c static char ** libxl_build_device_model_args_new(libxl__gc *gc, · line 1259
Quoted 6 lines
tools/libxl/libxl.c +1
-2@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (!dm_args)return NULL ; -flexarray_set (dm_args, num++,"qemu-system-xen" ); -flexarray_set (dm_args, num++,"-xen-domid" ); +flexarray_set (dm_args, num++,"qemu-dm" );
This bit doesn't seem to correspond to the patch description, was the change deliberate or did it slip in by mistake?
(my kingdom for flexarray_append(...))
Ian.
Re: [PATCH 2/5] libxl: strdup disk path before put it in qemu args array.
Quoted 18 lines · Ian Campbell
Quoted 17 lines · On Thu, 2010-12-09 at 19:42 +0000, [email protected] wrote:
From: Anthony PERARD <[email protected]>
In
libxl_build_device_model_args_new, the path to the disk image are freeed before there was actually use to make the arguments list of Qemu. The patch strdups it.--- tools/libxl/libxl.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (!dm_args)return NULL ;
Quoted 6 lines
tools/libxl/libxl.c static char ** libxl_build_device_model_args_new(libxl__gc *gc, · line 1259
Quoted 3 lines
tools/libxl/libxl.c +1
-2-flexarray_set (dm_args, num++,"qemu-system-xen" ); -flexarray_set (dm_args, num++,"-xen-domid" ); +flexarray_set (dm_args, num++,"qemu-dm" );This bit doesn't seem to correspond to the patch description, was the change deliberate or did it slip in by mistake?
This change was deliberate. As this hunk don't really change anything, I just don't explain it in the commit message. But I should have said the following in the description.
Also it changes argv[0] of the device model from "qemu-system-xen" to "qemu-dm".
I will resend the patch.
Quoted 1 line
(my kingdom for
flexarray_append(...))
It will be too easy with this functions :)
Signature · 1 line
Anthony PERARD
PATCH 2/5 libxl: strdup disk path before put it in qemu args array.
From: Anthony PERARD <[email protected]>
In libxl_build_device_model_args_new, the path to the disk image are freeed before there was actually use to make the arguments list of Qemu. The patch strdups it.
Also it changes argv[0] of the device model from "qemu-system-xen" to "qemu-dm".
--- tools/libxl/libxl.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +5 -5
@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (!dm_args)return NULL ; -flexarray_set (dm_args, num++,"qemu-system-xen" ); -flexarray_set (dm_args, num++,"-xen-domid" ); +flexarray_set (dm_args, num++,"qemu-dm" ); +flexarray_set (dm_args, num++,"-xen-domid" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->domid));if (info->dom_name) {
@@ -1378,10 +1378,10 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,for (i; i < nb; i++) {if ( disks[i].is_cdrom ) {flexarray_set (dm_args, num++,"-cdrom" ); -flexarray_set (dm_args, num++, disks[i].physpath); - }else { +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); + }else {flexarray_set (dm_args, num++,libxl__sprintf (gc,"-%s" , disks[i].virtpath)); -flexarray_set (dm_args, num++, disks[i].physpath); +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); }libxl_device_disk_destroy (&disks[i]); }
Signature · 1 line
1.7.1
Re: [PATCH 2/5] libxl: strdup disk path before put it in qemu args array.
In reply to Anthony PERARDQuoted 19 lines · Anthony Perard
Quoted 10 lines · Ian Campbell
Quoted 9 lines · On Thu, 2010-12-09 at 19:42 +0000, [email protected] wrote:
tools/libxl/libxl.c +0
-0@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (!dm_args)return NULL ;Quoted 6 lines
tools/libxl/libxl.c static char ** libxl_build_device_model_args_new(libxl__gc *gc, · line 1259
Quoted 3 lines
tools/libxl/libxl.c +1
-2-flexarray_set (dm_args, num++,"qemu-system-xen" ); -flexarray_set (dm_args, num++,"-xen-domid" ); +flexarray_set (dm_args, num++,"qemu-dm" );This bit doesn't seem to correspond to the patch description, was the change deliberate or did it slip in by mistake?
Quoted 6 lines
This change was deliberate. As this hunk don't really change anything, I just don't explain it in the commit message. But I should have said the following in the description.
Also it changes argv[0] of the device model from "qemu-system-xen" to "qemu-dm".
In the non-stubdom case convention would be for argv[0] to contain info->device_model (or is it "libxl__abs_path(&gc, info->device_model, libxl_libexec_path()),"? eurk).
In the stubdom case I guess it might as well be whatever we like.
Ian.
Re: [PATCH 2/5] libxl: strdup disk path before put it in qemu args array.
Quoted 24 lines · Ian Campbell
Quoted 23 lines · Anthony Perard
Quoted 10 lines · Ian Campbell
Quoted 9 lines · On Thu, 2010-12-09 at 19:42 +0000, [email protected] wrote:
tools/libxl/libxl.c +0
-0@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (!dm_args)return NULL ;Quoted 6 lines
tools/libxl/libxl.c static char ** libxl_build_device_model_args_new(libxl__gc *gc, · line 1259
Quoted 3 lines
tools/libxl/libxl.c +1
-2-flexarray_set (dm_args, num++,"qemu-system-xen" ); -flexarray_set (dm_args, num++,"-xen-domid" ); +flexarray_set (dm_args, num++,"qemu-dm" );This bit doesn't seem to correspond to the patch description, was the change deliberate or did it slip in by mistake?
This change was deliberate. As this hunk don't really change anything, I just don't explain it in the commit message. But I should have said the following in the description.
Quoted 6 lines
Quoted 2 lines
Also it changes argv[0] of the device model from "qemu-system-xen" to "qemu-dm".
In the non-stubdom case convention would be for argv[0] to contain
info->device_model(or is it "libxl__abs_path(&gc, info->device_model, libxl_libexec_path()),"? eurk).
Yes, this will be a little bit better, with info->device_model, like a shell would do.
Quoted 1 line
In the stubdom case I guess it might as well be whatever we like.
Signature · 1 line
Anthony PERARD
PATCH 2/5 libxl: strdup disk path before put it in qemu args array.
From: Anthony PERARD <[email protected]>
In libxl_build_device_model_args_new, the path to the disk image are freeed before there was actually use to make the arguments list of Qemu. The patch strdups it.
Also it changes argv[0] of the device model from "qemu-system-xen" to "qemu-dm".
--- tools/libxl/libxl.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +5 -5
@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (!dm_args)return NULL ; -flexarray_set (dm_args, num++,"qemu-system-xen" ); -flexarray_set (dm_args, num++,"-xen-domid" ); +flexarray_set (dm_args, num++,libxl__strdup (gc, info->device_model)); +flexarray_set (dm_args, num++,"-xen-domid" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->domid));if (info->dom_name) {
@@ -1378,10 +1378,10 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,for (i; i < nb; i++) {if ( disks[i].is_cdrom ) {flexarray_set (dm_args, num++,"-cdrom" ); -flexarray_set (dm_args, num++, disks[i].physpath); - }else { +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); + }else {flexarray_set (dm_args, num++,libxl__sprintf (gc,"-%s" , disks[i].virtpath)); -flexarray_set (dm_args, num++, disks[i].physpath); +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); }libxl_device_disk_destroy (&disks[i]); }
Signature · 1 line
1.7.1
PATCH 3/5 libxl: Specify the target ram size to Qemu (new) when calling it
In reply to [email protected]From: Anthony PERARD <[email protected]>
This patch adds target_ram in device_model_info structure, to be used in libxl_build_device_model_args_new. Qemu upstream needs to know about it.
--- tools/libxl/libxl.c | 4 ++++ tools/libxl/libxl.idl | 1 + tools/libxl/xl_cmdimpl.c | 1 + 3 files changed, 6 insertions(+), 0 deletions(-)
tools/libxl/libxl.c +4 -0
@@ -1374,6 +1374,10 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,else flexarray_set (dm_args, num++,"xenfv" ); +/* RAM Size */ +flexarray_set (dm_args, num++,"-m" ); +flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->target_ram)); + disks =libxl_device_disk_list (libxl__gc_owner (gc), info->domid, &nb);for (i; i < nb; i++) {if ( disks[i].is_cdrom ) {
tools/libxl/libxl.idl +1 -0
@@ -139,6 +139,7 @@ libxl_device_model_info = Struct("device_model_info",[ ("device_model", string), ("saved_state", string), ("type", libxl_qemu_machine_type), + ("target_ram", uint32), ("videoram", integer, False, "size of the videoram in MB"), ("stdvga", bool, False, "stdvga enabled or disabled"), ("vnc", bool, False, "vnc enabled or disabled"),
tools/libxl/xl_cmdimpl.c +1 -0
@@ -359,6 +359,7 @@ static void init_dm_info(libxl_device_model_info *dm_info, dm_info->dom_name =strdup (c_info->name); dm_info->device_model =strdup ("qemu-dm" ); + dm_info->target_ram = b_info->target_memkb /1024 ; dm_info->videoram = b_info->video_memkb /1024 ; dm_info->apic = b_info->u.hvm.apic; dm_info->vcpus = b_info->max_vcpus;
Signature · 1 line
1.7.1
PATCH 4/5 libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
In reply to [email protected]From: Anthony PERARD <[email protected]>
In libxl_build_device_model_args_new:
- Adds -xen-attach options to the list of arguments to Qemu.
- Adds -vga xenfb options when vnc and sdl are not set.
- Remove disk list from the command line for XenPV as they will be read from xenstore by Qemu.
--- tools/libxl/libxl.c | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +21 -9
@@ -1261,6 +1261,10 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,flexarray_set (dm_args, num++,"-xen-domid" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->domid)); +if (info->type ==XENPV ) { +flexarray_set (dm_args, num++,"-xen-attach" ); + } +if (info->dom_name) {flexarray_set (dm_args, num++,"-name" );flexarray_set (dm_args, num++, info->dom_name);
@@ -1292,6 +1296,12 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,if (info->sdl) {flexarray_set (dm_args, num++,"-sdl" ); } + +if (info->type ==XENPV && !info->nographic) { +flexarray_set (dm_args, num++,"-vga" ); +flexarray_set (dm_args, num++,"xenfb" ); + } +if (info->keymap) {flexarray_set (dm_args, num++,"-k" );flexarray_set (dm_args, num++, info->keymap);
@@ -1378,16 +1388,18 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,flexarray_set (dm_args, num++,"-m" );flexarray_set (dm_args, num++,libxl__sprintf (gc,"%d" , info->target_ram)); - disks =libxl_device_disk_list (libxl__gc_owner (gc), info->domid, &nb); -for (i; i < nb; i++) { -if ( disks[i].is_cdrom ) { -flexarray_set (dm_args, num++,"-cdrom" ); -flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); - }else { -flexarray_set (dm_args, num++,libxl__sprintf (gc,"-%s" , disks[i].virtpath)); -flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); +if (info->type ==XENFV ) { + disks =libxl_device_disk_list (libxl__gc_owner (gc), info->domid, &nb); +for (i; i < nb; i++) { +if (disks[i].is_cdrom) { +flexarray_set (dm_args, num++,"-cdrom" ); +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); + }else { +flexarray_set (dm_args, num++,libxl__sprintf (gc,"-%s" , disks[i].virtpath)); +flexarray_set (dm_args, num++,libxl__strdup (gc, disks[i].physpath)); + } +libxl_device_disk_destroy (&disks[i]); } -libxl_device_disk_destroy (&disks[i]); }free (disks);flexarray_set (dm_args, num++,NULL );
Signature · 1 line
1.7.1
Re: [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
[email protected] writes ("[Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 4 lines
From: Anthony PERARD <[email protected]>
In
libxl_build_device_model_args_new:
- Adds -xen-attach options to the list of arguments to Qemu.
Is that understood by qemu-xen ?
Ian.
Re: [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
Quoted 7 lines · Ian Jackson
[email protected] writes ("[Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 4 lines
From: Anthony PERARD <[email protected]>
In
libxl_build_device_model_args_new:
- Adds -xen-attach options to the list of arguments to Qemu.Is that understood by qemu-xen ?
Not really, it is understood by Qemu only when we have this:
#if defined(CONFIG_XEN) && !defined(CONFIG_DM).
And even in this case, it will do nothing because the variable that receives the option is write only, it is never read.
So the answer is no, it is not understood by Qemu.
Signature · 1 line
Anthony PERARD
Re: [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
Quoted 11 lines · Anthony PERARD
Quoted 7 lines · Ian Jackson
[email protected] writes ("[Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 4 lines
From: Anthony PERARD <[email protected]>
In
libxl_build_device_model_args_new:
- Adds -xen-attach options to the list of arguments to Qemu.Is that understood by qemu-xen ?
Quoted 7 lines
Not really, it is understood by Qemu only when we have this:
#ifdefined(CONFIG_XEN)&& !defined(CONFIG_DM).And even in this case, it will do nothing because the variable that receives the option is write only, it is never read.
So the answer is no, it is not understood by Qemu.
You will read qemux-xen, here ...
Signature · 1 line
Anthony PERARD
Re: [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
In reply to Anthony PERARDAnthony PERARD writes ("Re: [Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 9 lines · Ian Jackson
Quoted 7 lines
[email protected] writes ("[Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 3 lines
From: Anthony PERARD <[email protected]>
Inlibxl_build_device_model_args_new:
- Adds -xen-attach options to the list of arguments to Qemu.Is that understood by qemu-xen ?
Quoted 7 lines
Not really, it is understood by Qemu only when we have this:
#ifdefined(CONFIG_XEN)&& !defined(CONFIG_DM).And even in this case, it will do nothing because the variable that receives the option is write only, it is never read.
So the answer is no, it is not understood by Qemu.
Your reply seems confusing to me. Are we talking about the same things ?
By "qemu-xen" I mean the old qemu tree which we are still using for xen-unstable. By "understood" I mean that the program will accept the option. You write "Qemu" but by "Qemu" I would normally understand the current upstream qemu (presumably with your Xen patch series).
If the option is not understood by qemu-xen then current xen-unstable will break if we apply your patch, surely ?
Ian.
Re: [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
Quoted 13 lines · Ian Jackson
Anthony PERARD writes ("Re: [Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 12 lines · Ian Jackson
Quoted 7 lines
[email protected] writes ("[Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 3 lines
From: Anthony PERARD <[email protected]>
Inlibxl_build_device_model_args_new:
- Adds -xen-attach options to the list of arguments to Qemu.Is that understood by qemu-xen ?
Not really, it is understood by Qemu only when we have this:
#ifdefined(CONFIG_XEN)&& !defined(CONFIG_DM).
Quoted 7 lines
Quoted 4 lines
And even in this case, it will do nothing because the variable that receives the option is write only, it is never read.
So the answer is no, it is not understood by Qemu.
Your reply seems confusing to me. Are we talking about the same things ?
Sorry, I make a typo in my mail. I was speaking about qemu-xen in my reply, and not qemu upstream.
Quoted 7 lines
By "qemu-xen" I mean the old qemu tree which we are still using for xen-unstable. By "understood" I mean that the program will accept the option. You write "Qemu" but by "Qemu" I would normally understand the current upstream qemu (presumably with your Xen patch series).
If the option is not understood by qemu-xen then current xen-unstable will break if we apply your patch, surely ?
No, because the arguments for qemu-xen are not make by the same function. There are two functions that do almost the same thing:
- libxl_build_device_model_args_old
this function make argument for qemu-xen, the one in xen-unstable.
- libxl_build_device_model_args_new
and this one make arguments for qemu (upstream).
Signature · 1 line
Anthony PERARD
Re: [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest.
Anthony PERARD writes ("Re: [Xen-devel] [PATCH 4/5] libxl: Makes libxl be able to call Qemu upstream for XenPV guest."):
Quoted 6 lines
No, because the arguments for qemu-xen are not make by the same function. There are two functions that do almost the same thing:
-libxl_build_device_model_args_old
this function make argument for qemu-xen, the one in xen-unstable.
-libxl_build_device_model_args_new
and this one make arguments for qemu (upstream).
Ah, thanks, I hadn't spotted that.
Ian.
PATCH 5/5 libxl: Lists qdisk device in libxl_device_disk_list
In reply to [email protected]From: Anthony PERARD <[email protected]>
As libxl switch to qdisk when blktap isn't available, this patch makes libxl_device_disk_list also list qdisk device. So libxl_build_device_model_args_new will be able to add qdisk device to the command line options of Qemu.
--- tools/libxl/libxl.c | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-)
tools/libxl/libxl.c +29 -1
@@ -2492,7 +2492,7 @@ int libxl_device_vkb_hard_shutdown(libxl_ctx *ctx, uint32_t domid)libxl_device_disk *libxl_device_disk_list (libxl_ctx *ctx,uint32_t domid,int *num) {libxl__gc gc =LIBXL_INIT_GC (ctx); -char *be_path_tap, *be_path_vbd; +char *be_path_tap, *be_path_vbd, *be_path_qdisk;libxl_device_disk *dend, *disks, *ret =NULL ;char **b, **l =NULL ;unsigned int numl, len;
@@ -2500,6 +2500,7 @@ libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx, uint32_t domid, int *n be_path_vbd =libxl__sprintf (&gc,"%s/backend/vbd/%d" ,libxl__xs_get_dompath (&gc,0 ), domid); be_path_tap =libxl__sprintf (&gc,"%s/backend/tap/%d" ,libxl__xs_get_dompath (&gc,0 ), domid); + be_path_qdisk =libxl__sprintf (&gc,"%s/backend/qdisk/%d" ,libxl__xs_get_dompath (&gc,0 ), domid); b = l =libxl__xs_directory (&gc,XBT_NULL , be_path_vbd, &numl);if (l) {
@@ -2542,6 +2543,33 @@ libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx, uint32_t domid, int *n disks->is_cdrom = !strcmp (type,"cdrom" ); } } + b = l =libxl__xs_directory (&gc,XBT_NULL , be_path_qdisk, &numl); +if (l) { + ret =realloc (ret,sizeof (libxl_device_disk) * (*num + numl)); + disks = ret + *num; + *num += numl; +for (dend = ret + *num; disks < dend; ++disks, ++l) { +char *physpath_tmp; + disks->backend_domid =0 ; + disks->domid = domid; + physpath_tmp =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (&gc,"%s/%s/params" , be_path_qdisk, *l), &len); +if (strchr (physpath_tmp,':' )) { + disks->physpath =strdup (strchr (physpath_tmp) +1 ); +free (physpath_tmp); + }else { + disks->physpath = physpath_tmp; + } +libxl_string_to_phystype (ctx,libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/%s/type" , be_path_qdisk, *l)), &(disks->phystype)); + disks->virtpath =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (&gc,"%s/%s/dev" , be_path_qdisk, *l), &len); + disks->unpluggable =atoi (libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/%s/removable" , be_path_qdisk, *l))); +if (!strcmp (libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/%s/mode" , be_path_qdisk, *l)),"w" )) + disks->readwrite =1 ; +else + disks->readwrite =0 ; + type =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/device-type" ,libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/%s/frontend" , be_path_qdisk, *l)))); + disks->is_cdrom = !strcmp (type,"cdrom" ); + } + }libxl__free_all (&gc);return ret; }
Signature · 1 line
1.7.1
Re: [PATCH 5/5] libxl: Lists qdisk device in libxl_device_disk_list
[email protected] writes ("[Xen-devel] [PATCH 5/5] libxl: Lists qdisk device in libxl_device_disk_list"):
Quoted 6 lines
From: Anthony PERARD <[email protected]>
As libxl switch to qdisk when blktap isn't available, this patch makes
libxl_device_disk_listalso list qdisk device. Solibxl_build_device_model_args_newwill be able to add qdisk device to the command line options of Qemu.
Did you compile this ?
libxl.c:2559:66: error: macro "strchr" requires 2 arguments, but only 1 given
cc1: warnings being treated as errorslibxl.c: In function 'libxl_device_disk_list':
libxl.c:2559: error: passing argument 1 of 'strlen' from incompatible pointer type libxl.c:2559: error: passing argument 1 of '__strdup' from incompatible pointer type
make: *** [libxl.o] Error 1
Ian.