From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v10 13/19] libxl: set correct nic type depending on the guest
Date: Fri, 20 Jul 2012 15:12:22 +0100 [thread overview]
Message-ID: <1342793548-10239-14-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1342793548-10239-1-git-send-email-roger.pau@citrix.com>
Fix the use of nic type, which results in the following for each type
of domain:
* HVM: let the user choose, if none specified use VIF_IOEMU.
* PV: use VIF always.
Changes since v9:
* Don't force nic type for HVM-stubdom guests.
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
tools/libxl/libxl.c | 20 ++++++++++++++++----
tools/libxl/libxl_create.c | 2 +-
tools/libxl/libxl_dm.c | 2 +-
tools/libxl/libxl_internal.h | 3 ++-
4 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 05ba211..5c5c876 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2375,7 +2375,8 @@ out:
/******************************************************************************/
-int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic)
+int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
+ uint32_t domid)
{
if (!nic->mtu)
nic->mtu = 1492;
@@ -2405,8 +2406,19 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic)
if ( !nic->script && asprintf(&nic->script, "%s/vif-bridge",
libxl__xen_script_dir_path()) < 0 )
return ERROR_FAIL;
- if (!nic->nictype)
- nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
+
+ switch (libxl__domain_type(gc, domid)) {
+ case LIBXL_DOMAIN_TYPE_HVM:
+ if (!nic->nictype)
+ nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
+ break;
+ case LIBXL_DOMAIN_TYPE_PV:
+ nic->nictype = LIBXL_NIC_TYPE_VIF;
+ break;
+ default:
+ abort();
+ }
+
return 0;
}
@@ -2434,7 +2446,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
char *dompath, **l;
unsigned int nb, rc;
- rc = libxl__device_nic_setdefault(gc, nic);
+ rc = libxl__device_nic_setdefault(gc, nic, domid);
if (rc) goto out;
front = flexarray_make(16, 1);
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index d3dc038..7db9457 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -938,7 +938,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs,
* called libxl_device_nic_add at this point, but qemu needs
* the nic information to be complete.
*/
- libxl__device_nic_setdefault(gc, &d_config->nics[i]);
+ libxl__device_nic_setdefault(gc, &d_config->nics[i], domid);
}
switch (d_config->c_info.type) {
case LIBXL_DOMAIN_TYPE_HVM:
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index f21fb4f..cbe518f 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -875,7 +875,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
* called libxl_device_nic_add at this point, but qemu needs
* the nic information to be complete.
*/
- libxl__device_nic_setdefault(gc, &dm_config->nics[i]);
+ libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid);
}
ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config->vfbs[0]);
if (ret)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index cd55da6..3d87030 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -897,7 +897,8 @@ _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc,
libxl_domain_build_info *b_info);
_hidden int libxl__device_disk_setdefault(libxl__gc *gc,
libxl_device_disk *disk);
-_hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic);
+_hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
+ uint32_t domid);
_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb);
_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb);
_hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci);
--
1.7.7.5 (Apple Git-26)
next prev parent reply other threads:[~2012-07-20 14:12 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 14:12 [PATCH v10 01/19] execute hotplug scripts from libxl v10 Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 01/19] libxl: check backend state before setting it to "closing" Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 02/19] libxl: change ao_device_remove to ao_device Roger Pau Monne
2012-07-20 16:35 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 03/19] libxl: move device model creation prototypes Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 04/19] libxl: convert libxl_domain_destroy to an async op Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 05/19] libxl: move bootloader data strucutres and prototypes Roger Pau Monne
2012-07-20 17:21 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 06/19] libxl: refactor disk addition to take a helper Roger Pau Monne
2012-07-20 17:24 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 07/19] libxl: convert libxl__device_disk_local_attach to an async op Roger Pau Monne
2012-07-20 18:03 ` Ian Jackson
2012-07-23 11:32 ` Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 08/19] libxl: rename vifs to nics Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 09/19] libxl: convert libxl_device_disk_add to an async op Roger Pau Monne
2012-07-20 18:04 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 10/19] libxl: convert libxl_device_nic_add to an async operation Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 11/19] libxl: add option to choose who executes hotplug scripts Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 12/19] libxl: rename _IOEMU nic type to VIF_IOEMU Roger Pau Monne
2012-07-20 16:34 ` Ian Campbell
2012-07-20 16:39 ` Ian Campbell
2012-07-20 14:12 ` Roger Pau Monne [this message]
2012-07-20 18:06 ` [PATCH v10 13/19] libxl: set correct nic type depending on the guest Ian Jackson
2012-07-20 14:12 ` [PATCH v10 14/19] libxl: use libxl__xs_path_cleanup on device_destroy Roger Pau Monne
2012-07-20 15:38 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 15/19] libxl: call hotplug scripts for disk devices from libxl Roger Pau Monne
2012-07-20 15:20 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 16/19] libxl: call hotplug scripts for nic " Roger Pau Monne
2012-07-20 16:01 ` Ian Campbell
2012-07-20 16:12 ` Ian Campbell
2012-07-20 16:36 ` Ian Campbell
2012-07-23 9:22 ` Roger Pau Monne
2012-07-20 16:03 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 17/19] libxl: convert libxl_device_vkb_add to an async operation Roger Pau Monne
2012-07-20 18:08 ` Ian Jackson
2012-07-23 8:58 ` Roger Pau Monne
2012-07-23 9:26 ` Ian Campbell
2012-07-23 11:44 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 18/19] libxl: convert libxl_device_vfb_add " Roger Pau Monne
2012-07-20 18:11 ` Ian Jackson
2012-07-23 11:58 ` Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 19/19] xl: main_blockdetach don't call destroy if remove succeeds Roger Pau Monne
2012-07-20 14:55 ` Ian Campbell
2012-07-23 12:17 ` [PATCH v10 01/19] execute hotplug scripts from libxl v10 Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342793548-10239-14-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).