From patchwork Thu Oct 5 09:30:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9986677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37E7A60247 for ; Thu, 5 Oct 2017 09:33:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26A3A28BE1 for ; Thu, 5 Oct 2017 09:33:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B24B28C0A; Thu, 5 Oct 2017 09:33:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B792128BE1 for ; Thu, 5 Oct 2017 09:33:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e02Ug-0005mD-P9; Thu, 05 Oct 2017 09:31:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e02Uf-0005j4-4j for xen-devel@lists.xenproject.org; Thu, 05 Oct 2017 09:31:01 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 99/8B-02226-4DBF5D95; Thu, 05 Oct 2017 09:31:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRWlGSWpSXmKPExsVyMfS6k+6F31c jDX79kLP4vmUykwOjx+EPV1gCGKNYM/OS8isSWDM+nTzKXtD6lrGi+eBC5gbG7o2MXYycHEIC 0xklXqwBs1kEXrJI/PhqC2JLCPSzSrx/6AVhZ0ls3HmKEcJOk3h+8TQThF0ucfLQJHaIOfISB 1suA9lcQPYUJom+fRBD2QS0JO7fXsEGYosIKEncWzUZrJlZIEVi77o2sBphAU+J0/P7mCCOUJ U4P/U8WD2vgIPEuRVzmCGWyUncPNcJZnMKOEp8+XaYDWKxg0R/z02mCYyCCxgZVjFqFKcWlaU W6Rqa6yUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBIYcAxDsYHx52vMQoyQHk5Io r9bXq5FCfEn5KZUZicUZ8UWlOanFhxg1ODgEfj7928IoxZKXn5eqJMHL9QGoTrAoNT21Ii0zB xgVMKUSHDxKIry/PwKleYsLEnOLM9MhUqcYLTku3Ln0h4njwJ5bQLLj5t0/TEJg86TEeXlB5g mANGSU5sGNg0XuJUZZKWFeRqBjhXgKUotyM0tQ5V8xinMwKgnz3gCZwpOZVwK39RXQQUxAB81 pugJyUEkiQkqqgbH35b2DP269SZbO+35UpkqMUSDYsSqQ+66h6dqAp/UL72QsOnrs37sk0Z97 +Pcqb+g8uuhC8J13x/iEbD88PnNg6zxJhmfevV0mV8+3LdE5pJN9wU5AskB39vV7HLsCxAQM9 u1szryw4dBrk8j2D/337JQv1xi8LOhUejp9XY2N0fmnmm9v3lyjxFKckWioxVxUnAgAKRvkZd cCAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1507195856!117326380!1 X-Originating-IP: [209.85.215.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61670 invoked from network); 5 Oct 2017 09:30:56 -0000 Received: from mail-lf0-f66.google.com (HELO mail-lf0-f66.google.com) (209.85.215.66) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 09:30:56 -0000 Received: by mail-lf0-f66.google.com with SMTP id 90so8068986lfs.13 for ; Thu, 05 Oct 2017 02:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wnj7wVlbd4gBnV4rKXQQu3JIAUyvjvQe42JV7HMOkRk=; b=EaDg5v5mMtnjZy5wMYDq8jF47weA6dNWGTZZ45qmDTKZGniB2F5CES9CoICE1LDFoZ cdgJoPlzyq+IHjzCZTC7FgWWVHF8rup6j6hpwd6WGHgFXboyCP6QfDojMdTdSUUzXIBb 5u6SKBtC4q4YvS+dhoRujK9MfEfkSZ2MFtZe+moyXshTjLJgExKiGwhIXOBeXCKb3QmD T3LD2avRJGrbOfmRor5PPtiz+VYadaqYsciGuvhSxGpppFDgzSR8u9udiYpVJC91Mr9E Tt5/8eIyJopEozA7FXv1oAB4Yr8AK9WeRRbL1j2QbaNg4ssRJ4QhCVSlTNbNr27MQsfF 24tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wnj7wVlbd4gBnV4rKXQQu3JIAUyvjvQe42JV7HMOkRk=; b=WV6tzFw+cdDBBqYka1J5qiGWCMSJlOM5lAk0DALX5uI+6v5Y0AE8isLzVncL0s39T4 CRK1kTepZXTs+RNJT+0HsBu6leiMOU0Ct7Gx1k+GcocmmP6Bx3Vk/cAuXNg5sNHK0CNO ksg8rKV4YVvWniUyw8omtr1rmAHMRG6p1DwJgzCvz+FcscGvwKMoozzUkI0yg949uaoa 2zSWP+Wi8Sm30fku1Kyjif05oe9PCkBJgd3lQYEmS1PcVxrcVxdx7A0w0/5MgXi5xxMc e3ScTwm9tujU5yIn66SOgcnBhX8jSCvDDPeHXGUZSvTQumfPvYXs9AyKQHtLqWxNeur4 ixUg== X-Gm-Message-State: AMCzsaX0h+EQd0+iQLJuEFAq0VtlbFXfpmzPPbMwMzxrmpUaw3AR+HFL rSjBuEXoIHRJuj5j1WkRZV82CA== X-Google-Smtp-Source: AOwi7QDjuAwlJM1AdeHWyxJUcZiCYnHGmCPcaGQXotH+8kfFqz4CliuDkBy8MEj1m4Mnady9P58ASQ== X-Received: by 10.25.18.71 with SMTP id h68mr5587677lfi.50.1507195855354; Thu, 05 Oct 2017 02:30:55 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-52.209.223.85.sovam.net.ua. [85.223.209.52]) by smtp.gmail.com with ESMTPSA id z1sm868340lja.42.2017.10.05.02.30.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 02:30:54 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 5 Oct 2017 12:30:45 +0300 Message-Id: <1507195848-18346-2-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507195848-18346-1-git-send-email-al1img@gmail.com> References: <1507195848-18346-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH 1/4] libxl: use libxl__device_kind to get device XS entry X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Grytsov On adding to XS name of device is taken from libxl__device_kind enum. On getting device from XS the name is hardcoded. It leads to potential mistmatch errors. The patch is using libxl__device_kind everywere to have one source of device name. Signed-off-by: Oleksandr Grytsov Acked-by: Wei Liu --- tools/libxl/libxl_9pfs.c | 2 +- tools/libxl/libxl_colo_nic.c | 6 ++++-- tools/libxl/libxl_console.c | 18 ++++++++++------ tools/libxl/libxl_create.c | 4 ++-- tools/libxl/libxl_device.c | 3 ++- tools/libxl/libxl_disk.c | 28 ++++++++++++++++-------- tools/libxl/libxl_domain.c | 2 +- tools/libxl/libxl_internal.h | 12 +++++------ tools/libxl/libxl_netbuffer.c | 6 ++++-- tools/libxl/libxl_nic.c | 16 +++++++++----- tools/libxl/libxl_pci.c | 21 ++++++++++++------ tools/libxl/libxl_usb.c | 50 ++++++++++++++++++++++++++++--------------- tools/libxl/libxl_vdispl.c | 9 +++++--- tools/libxl/libxl_vkb.c | 9 +++++--- tools/libxl/libxl_vsnd.c | 9 +++++--- tools/libxl/libxl_vtpm.c | 12 +++++++---- 16 files changed, 135 insertions(+), 72 deletions(-) diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c index 9db887b..c3dd786 100644 --- a/tools/libxl/libxl_9pfs.c +++ b/tools/libxl/libxl_9pfs.c @@ -58,7 +58,7 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid, LIBXL_DEFINE_DEVICE_REMOVE(p9) -DEFINE_DEVICE_TYPE_STRUCT(p9, +DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, .skip_attach = 1, .set_xenstore_config = (device_set_xenstore_config_fn_t) libxl__set_xenstore_p9, diff --git a/tools/libxl/libxl_colo_nic.c b/tools/libxl/libxl_colo_nic.c index a164e22..71a17fd 100644 --- a/tools/libxl/libxl_colo_nic.c +++ b/tools/libxl/libxl_colo_nic.c @@ -60,8 +60,10 @@ static const char *get_vifname(libxl__checkpoint_device *dev, /* Convenience aliases */ const uint32_t domid = dev->cds->domid; - path = GCSPRINTF("%s/backend/vif/%d/%d/vifname", - libxl__xs_get_dompath(gc, 0), domid, nic->devid); + path = GCSPRINTF("%s/backend/%s/%d/%d/vifname", + libxl__xs_get_dompath(gc, 0), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VIF), + domid, nic->devid); rc = libxl__xs_read_checked(gc, XBT_NULL, path, &vifname); if (!rc && !vifname) { vifname = libxl__device_nic_devname(gc, domid, diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 09facaf..b7c0d34 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -37,7 +37,9 @@ static int libxl__console_tty_path(libxl__gc *gc, uint32_t domid, int cons_num, if (cons_num == 0) *tty_path = GCSPRINTF("%s/console/tty", dom_path); else - *tty_path = GCSPRINTF("%s/device/console/%d/tty", dom_path, + *tty_path = GCSPRINTF("%s/device/%s/%d/tty", dom_path, + libxl__device_kind_to_string( + LIBXL__DEVICE_KIND_CONSOLE), cons_num); rc = 0; break; @@ -450,8 +452,10 @@ static int libxl__append_channel_list(libxl__gc *gc, libxl_device_channel *next = NULL; int rc = 0, i; - libxl_dir_path = GCSPRINTF("%s/device/console", - libxl__xs_libxl_path(gc, domid)); + libxl_dir_path = GCSPRINTF("%s/device/%s", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string( + LIBXL__DEVICE_KIND_CONSOLE)); dir = libxl__xs_directory(gc, XBT_NULL, libxl_dir_path, &n); if (!dir || !n) goto out; @@ -523,10 +527,12 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, dompath = libxl__xs_get_dompath(gc, domid); channelinfo->devid = channel->devid; - fe_path = GCSPRINTF("%s/device/console/%d", dompath, + fe_path = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_CONSOLE), channelinfo->devid + 1); - libxl_path = GCSPRINTF("%s/device/console/%d", + libxl_path = GCSPRINTF("%s/device/%s/%d", libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_CONSOLE), channelinfo->devid + 1); channelinfo->backend = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/backend", libxl_path), NULL); @@ -682,7 +688,7 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid, /* vfb */ LIBXL_DEFINE_DEVICE_REMOVE(vfb) -DEFINE_DEVICE_TYPE_STRUCT(vfb, +DEFINE_DEVICE_TYPE_STRUCT(vfb, VFB, .skip_attach = 1, .set_xenstore_config = (device_set_xenstore_config_fn_t) libxl__set_xenstore_vfb, diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 7268f7f..31df0c6 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1442,7 +1442,7 @@ out: #define libxl__device_from_dtdev NULL #define libxl__device_dtdev_setdefault NULL #define libxl__device_dtdev_update_devid NULL -static DEFINE_DEVICE_TYPE_STRUCT(dtdev); +static DEFINE_DEVICE_TYPE_STRUCT(dtdev, NONE); const struct libxl_device_type *device_type_tbl[] = { &libxl__disk_devtype, @@ -1469,7 +1469,7 @@ static void domcreate_attach_devices(libxl__egc *egc, if (ret) { LOGD(ERROR, domid, "unable to add %s devices", - device_type_tbl[dcs->device_type_idx]->type); + libxl__device_kind_to_string(device_type_tbl[dcs->device_type_idx]->type)); goto error_out; } diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 46ca5a4..7aaf493 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -2002,7 +2002,8 @@ void *libxl__device_list(libxl__gc *gc, const struct libxl_device_type *dt, *num = 0; libxl_path = GCSPRINTF("%s/device/%s", - libxl__xs_libxl_path(gc, domid), dt->entry); + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(dt->type)); dir = libxl__xs_directory(gc, XBT_NULL, libxl_path, &ndirs); diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index 263cb56..13d3646 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -97,12 +97,14 @@ int libxl_evenable_disk_eject(libxl_ctx *ctx, uint32_t guest_domid, int devid = libxl__device_disk_dev_number(vdev, NULL, NULL); - path = GCSPRINTF("%s/device/vbd/%d/eject", + path = GCSPRINTF("%s/device/%s/%d/eject", + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VBD), libxl__xs_get_dompath(gc, domid), devid); if (!path) { rc = ERROR_NOMEM; goto out; } - const char *libxl_path = GCSPRINTF("%s/device/vbd/%d", + const char *libxl_path = GCSPRINTF("%s/device/%s/%d", + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VBD), libxl__xs_libxl_path(gc, domid), devid); evg->be_ptr_path = libxl__sprintf(NOGC, "%s/backend", libxl_path); @@ -614,7 +616,9 @@ int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid, if (!dom_xl_path) { goto out; } - libxl_path = GCSPRINTF("%s/device/vbd/%d", dom_xl_path, devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", dom_xl_path, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VBD), + devid); rc = libxl__disk_from_xenstore(gc, libxl_path, devid, disk); out: @@ -636,9 +640,13 @@ int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid, diskinfo->devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL); /* tap devices entries in xenstore are written as vbd devices. */ - fe_path = GCSPRINTF("%s/device/vbd/%d", dompath, diskinfo->devid); - libxl_path = GCSPRINTF("%s/device/vbd/%d", - libxl__xs_libxl_path(gc, domid), diskinfo->devid); + fe_path = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VBD), + diskinfo->devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VBD), + diskinfo->devid); diskinfo->backend = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/backend", libxl_path), NULL); if (!diskinfo->backend) { @@ -893,8 +901,10 @@ static char * libxl__alloc_vdev(libxl__gc *gc, void *get_vdev_user, if (devid < 0) return NULL; if (libxl__xs_read(gc, t, - GCSPRINTF("%s/device/vbd/%d/backend", - libxl_dom_path, devid)) == NULL) { + GCSPRINTF("%s/device/%s/%d/backend", + libxl_dom_path, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VBD), + devid)) == NULL) { if (errno == ENOENT) return libxl__devid_to_vdev(gc, devid); else @@ -1187,7 +1197,7 @@ LIBXL_DEFINE_DEVICE_LIST(disk) #define libxl__device_disk_update_devid NULL -DEFINE_DEVICE_TYPE_STRUCT_X(disk, disk, vbd, +DEFINE_DEVICE_TYPE_STRUCT(disk, VBD, .merge = libxl_device_disk_merge, .dm_needed = libxl_device_disk_dm_needed, .from_xenstore = (device_from_xenstore_fn_t)libxl__disk_from_xenstore, diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 0434ab9..ef1a092 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1686,7 +1686,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, p = libxl__device_list(gc, dt, domid, &num); if (p == NULL) { LOGD(DEBUG, domid, "No %s from xenstore", - dt->type); + libxl__device_kind_to_string(dt->type)); } devs = libxl__device_type_get_ptr(dt, d_config); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 6b403dc..10ad52f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3500,8 +3500,7 @@ typedef int (*device_set_xenstore_config_fn_t)(libxl__gc *, uint32_t, void *, flexarray_t *); struct libxl_device_type { - char *type; - char *entry; + libxl__device_kind type; int skip_attach; /* Skip entry in domcreate_attach_devices() if 1 */ int ptr_offset; /* Offset of device array ptr in libxl_domain_config */ int num_offset; /* Offset of # of devices in libxl_domain_config */ @@ -3521,10 +3520,9 @@ struct libxl_device_type { device_set_xenstore_config_fn_t set_xenstore_config; }; -#define DEFINE_DEVICE_TYPE_STRUCT_X(name, sname, sentry, ...) \ +#define DEFINE_DEVICE_TYPE_STRUCT_X(name, sname, kind, ...) \ const struct libxl_device_type libxl__ ## name ## _devtype = { \ - .type = #sname, \ - .entry = #sentry, \ + .type = LIBXL__DEVICE_KIND_ ## kind, \ .ptr_offset = offsetof(libxl_domain_config, name ## s), \ .num_offset = offsetof(libxl_domain_config, num_ ## name ## s), \ .dev_elem_size = sizeof(libxl_device_ ## sname), \ @@ -3543,8 +3541,8 @@ struct libxl_device_type { __VA_ARGS__ \ } -#define DEFINE_DEVICE_TYPE_STRUCT(name, ...) \ - DEFINE_DEVICE_TYPE_STRUCT_X(name, name, name, __VA_ARGS__) +#define DEFINE_DEVICE_TYPE_STRUCT(name, kind, ...) \ + DEFINE_DEVICE_TYPE_STRUCT_X(name, name, kind, __VA_ARGS__) static inline void **libxl__device_type_get_ptr( const struct libxl_device_type *dt, const libxl_domain_config *d_config) diff --git a/tools/libxl/libxl_netbuffer.c b/tools/libxl/libxl_netbuffer.c index 323cdd8..6690ce5 100644 --- a/tools/libxl/libxl_netbuffer.c +++ b/tools/libxl/libxl_netbuffer.c @@ -126,8 +126,10 @@ static const char *get_vifname(libxl__checkpoint_device *dev, /* Convenience aliases */ const uint32_t domid = dev->cds->domid; - path = GCSPRINTF("%s/backend/vif/%d/%d/vifname", - libxl__xs_get_dompath(gc, 0), domid, nic->devid); + path = GCSPRINTF("%s/backend/%s/%d/%d/vifname", + libxl__xs_get_dompath(gc, 0), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VIF), + domid, nic->devid); rc = libxl__xs_read_checked(gc, XBT_NULL, path, &vifname); if (!rc && !vifname) { vifname = libxl__device_nic_devname(gc, domid, diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c index 9daecf7..44d0fa7 100644 --- a/tools/libxl/libxl_nic.c +++ b/tools/libxl/libxl_nic.c @@ -409,7 +409,9 @@ int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid, if (!libxl_dom_path) goto out; - libxl_path = GCSPRINTF("%s/device/vif/%d", libxl_dom_path, devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", libxl_dom_path, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VIF), + devid); rc = libxl__nic_from_xenstore(gc, libxl_path, devid, nic); if (rc) goto out; @@ -449,9 +451,13 @@ int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid, dompath = libxl__xs_get_dompath(gc, domid); nicinfo->devid = nic->devid; - nicpath = GCSPRINTF("%s/device/vif/%d", dompath, nicinfo->devid); - libxl_path = GCSPRINTF("%s/device/vif/%d", - libxl__xs_libxl_path(gc, domid), nicinfo->devid); + nicpath = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VIF), + nicinfo->devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VIF), + nicinfo->devid); nicinfo->backend = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/backend", libxl_path), NULL); if (!nicinfo->backend) { @@ -540,7 +546,7 @@ LIBXL_DEFINE_DEVICE_ADD(nic) LIBXL_DEFINE_DEVICES_ADD(nic) LIBXL_DEFINE_DEVICE_REMOVE(nic) -DEFINE_DEVICE_TYPE_STRUCT_X(nic, nic, vif, +DEFINE_DEVICE_TYPE_STRUCT(nic, VIF, .update_config = libxl_device_nic_update_config, .from_xenstore = (device_from_xenstore_fn_t)libxl__nic_from_xenstore, .set_xenstore_config = (device_set_xenstore_config_fn_t) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 88a55ce..f83ac32 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -125,7 +125,9 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d libxl_device_pci_init(&pcidev_saved); libxl_device_pci_copy(CTX, &pcidev_saved, pcidev); - be_path = GCSPRINTF("%s/backend/pci/%d/0", libxl__xs_get_dompath(gc, 0), domid); + be_path = GCSPRINTF("%s/backend/%s/%d/0", libxl__xs_get_dompath(gc, 0), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_PCI), + domid); num_devs = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/num_devs", be_path)); if (!num_devs) return libxl__create_pci_backend(gc, domid, pcidev, 1); @@ -195,7 +197,9 @@ static int libxl__device_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, libx int num, i, j; xs_transaction_t t; - be_path = GCSPRINTF("%s/backend/pci/%d/0", libxl__xs_get_dompath(gc, 0), domid); + be_path = GCSPRINTF("%s/backend/%s/%d/0", libxl__xs_get_dompath(gc, 0), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_PCI), + domid); num_devs_path = GCSPRINTF("%s/num_devs", be_path); num_devs = libxl__xs_read(gc, XBT_NULL, num_devs_path); if (!num_devs) @@ -315,14 +319,17 @@ static int get_all_assigned_devices(libxl__gc *gc, libxl_device_pci **list, int for(i = 0; i < nd; i++) { char *path, *num_devs; - path = GCSPRINTF("/local/domain/0/backend/pci/%s/0/num_devs", domlist[i]); + path = GCSPRINTF("/local/domain/0/backend/%s/%s/0/num_devs", + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_PCI), + domlist[i]); num_devs = libxl__xs_read(gc, XBT_NULL, path); if ( num_devs ) { int ndev = atoi(num_devs), j; char *devpath, *bdf; for(j = 0; j < ndev; j++) { - devpath = GCSPRINTF("/local/domain/0/backend/pci/%s/0/dev-%u", + devpath = GCSPRINTF("/local/domain/0/backend/%s/%s/0/dev-%u", + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_PCI), domlist[i], j); bdf = libxl__xs_read(gc, XBT_NULL, devpath); if ( bdf ) { @@ -1589,7 +1596,9 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, uint32_t domid, int *num *num = 0; - be_path = GCSPRINTF("%s/backend/pci/%d/0", libxl__xs_get_dompath(gc, 0), domid); + be_path = GCSPRINTF("%s/backend/%s/%d/0", libxl__xs_get_dompath(gc, 0), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_PCI), + domid); num_devs = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/num_devs", be_path)); if (!num_devs) goto out; @@ -1682,7 +1691,7 @@ static int libxl_device_pci_compare(libxl_device_pci *d1, #define libxl__device_pci_update_devid NULL -DEFINE_DEVICE_TYPE_STRUCT_X(pcidev, pci, pci); +DEFINE_DEVICE_TYPE_STRUCT_X(pcidev, pci, PCI); /* * Local variables: diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 1d5a243..6ce6957 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -310,8 +310,10 @@ static void libxl__device_usbctrl_del_xenstore(libxl__gc *gc, uint32_t domid, xs_transaction_t t = XBT_NULL; int rc; - libxl_path = GCSPRINTF("%s/device/vusb/%d", - libxl__xs_libxl_path(gc, domid), usbctrl->devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB), + usbctrl->devid); be_path = vusb_be_from_xs_libxl_type(gc, libxl_path, usbctrl->type); for (;;) { @@ -574,8 +576,9 @@ libxl_device_usbctrl_list(libxl_ctx *ctx, uint32_t domid, int *num) *num = 0; - libxl_vusbs_path = GCSPRINTF("%s/device/vusb", - libxl__xs_libxl_path(gc, domid)); + libxl_vusbs_path = GCSPRINTF("%s/device/%s", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB)); entry = libxl__xs_directory(gc, XBT_NULL, libxl_vusbs_path, &nentries); if (entry && nentries) { @@ -667,13 +670,17 @@ int libxl_device_usbctrl_getinfo(libxl_ctx *ctx, uint32_t domid, }) libxl_dom_path = libxl__xs_libxl_path(gc, domid); - libxl_path = GCSPRINTF("%s/device/vusb/%d", libxl_dom_path, usbctrl->devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", libxl_dom_path, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB), + usbctrl->devid); libxl_usbctrl_type_from_string(READ_SUBPATH(libxl_path, "type"), &usbctrlinfo->type); if (usbctrlinfo->type != LIBXL_USBCTRL_TYPE_DEVICEMODEL) { dompath = libxl__xs_get_dompath(gc, domid); - fe_path = GCSPRINTF("%s/device/vusb/%d", dompath, usbctrl->devid); + fe_path = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB), + usbctrl->devid); be_path = READ_SUBPATH(libxl_path, "backend"); usbctrlinfo->backend = libxl__strdup(NOGC, be_path); rc = libxl__backendpath_parse_domid(gc, be_path, @@ -821,8 +828,9 @@ static int get_assigned_devices(libxl__gc *gc, unsigned int nc = 0; uint32_t domid = atoi(domlist[i]); - libxl_vusbs_path = GCSPRINTF("%s/device/vusb", - libxl__xs_libxl_path(gc, domid)); + libxl_vusbs_path = GCSPRINTF("%s/device/%s", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB)); usbctrls = libxl__xs_directory(gc, XBT_NULL, libxl_vusbs_path, &nc); @@ -900,8 +908,10 @@ libxl__device_usbdev_list_for_usbctrl(libxl__gc *gc, *usbdevs = NULL; *num = 0; - libxl_path = GCSPRINTF("%s/device/vusb/%d", - libxl__xs_libxl_path(gc, domid), usbctrl); + libxl_path = GCSPRINTF("%s/device/%s/%d", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB), + usbctrl); be_path = vusb_be_from_xs_libxl(gc, libxl_path); if (!be_path) { @@ -959,8 +969,10 @@ libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t domid, int *num) *num = 0; - libxl_vusbs_path = GCSPRINTF("%s/device/vusb", - libxl__xs_libxl_path(gc, domid)); + libxl_vusbs_path = GCSPRINTF("%s/device/%s", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string( + LIBXL__DEVICE_KIND_VUSB)); usbctrls = libxl__xs_directory(gc, XBT_NULL, libxl_vusbs_path, &nc); for (i = 0; i < nc; i++) { @@ -990,7 +1002,8 @@ static char *vusb_get_port_path(libxl__gc *gc, uint32_t domid, char *path; if (type == LIBXL_USBCTRL_TYPE_DEVICEMODEL) - path = GCSPRINTF("%s/device/vusb", libxl__xs_libxl_path(gc, domid)); + path = GCSPRINTF("%s/device/%s", libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB)); else path = GCSPRINTF("%s/backend/%s/%d", libxl__xs_get_dompath(gc, LIBXL_TOOLSTACK_DOMID), @@ -1096,8 +1109,9 @@ static int libxl__device_usbdev_setdefault(libxl__gc *gc, /* A controller was specified; look it up */ const char *libxl_path, *be_path, *tmp; - libxl_path = GCSPRINTF("%s/device/vusb/%d", + libxl_path = GCSPRINTF("%s/device/%s/%d", libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB), usbdev->ctrl); be_path = vusb_be_from_xs_libxl(gc, libxl_path); @@ -1893,7 +1907,9 @@ int libxl_ctrlport_to_device_usbdev(libxl_ctx *ctx, libxl_dom_path = libxl__xs_libxl_path(gc, domid); - libxl_path = GCSPRINTF("%s/device/vusb/%d", libxl_dom_path, ctrl); + libxl_path = GCSPRINTF("%s/device/%s/%d", libxl_dom_path, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VUSB), + ctrl); be_path = vusb_be_from_xs_libxl(gc, libxl_path); if (!be_path) { rc = ERROR_FAIL; @@ -1962,14 +1978,14 @@ void libxl_device_usbdev_list_free(libxl_device_usbdev *list, int nr) #define libxl__device_usbctrl_update_devid NULL -DEFINE_DEVICE_TYPE_STRUCT(usbctrl, +DEFINE_DEVICE_TYPE_STRUCT(usbctrl, VUSB, .dm_needed = libxl_device_usbctrl_dm_needed ); #define libxl__device_from_usbdev NULL #define libxl__device_usbdev_update_devid NULL -DEFINE_DEVICE_TYPE_STRUCT(usbdev); +DEFINE_DEVICE_TYPE_STRUCT(usbdev, VUSB); /* * Local variables: diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c index e61ef2d..31409a4 100644 --- a/tools/libxl/libxl_vdispl.c +++ b/tools/libxl/libxl_vdispl.c @@ -176,9 +176,12 @@ int libxl_device_vdispl_getinfo(libxl_ctx *ctx, uint32_t domid, dompath = libxl__xs_get_dompath(gc, domid); info->devid = vdispl->devid; - devpath = GCSPRINTF("%s/device/vdispl/%d", dompath, info->devid); - libxl_path = GCSPRINTF("%s/device/vdispl/%d", + devpath = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VDISPL), + info->devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VDISPL), info->devid); info->backend = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/backend", libxl_path), @@ -249,7 +252,7 @@ LIBXL_DEFINE_DEVICE_REMOVE(vdispl) static LIBXL_DEFINE_UPDATE_DEVID(vdispl, "vdispl") LIBXL_DEFINE_DEVICE_LIST(vdispl) -DEFINE_DEVICE_TYPE_STRUCT(vdispl, +DEFINE_DEVICE_TYPE_STRUCT(vdispl, VDISPL, .update_config = (device_update_config_fn_t)libxl__update_config_vdispl, .from_xenstore = (device_from_xenstore_fn_t)libxl__vdispl_from_xenstore, .set_xenstore_config = (device_set_xenstore_config_fn_t) diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c index 276cc8a..1cd7feb 100644 --- a/tools/libxl/libxl_vkb.c +++ b/tools/libxl/libxl_vkb.c @@ -122,9 +122,12 @@ int libxl_device_vkb_getinfo(libxl_ctx *ctx, uint32_t domid, dompath = libxl__xs_get_dompath(gc, domid); info->devid = vkb->devid; - devpath = GCSPRINTF("%s/device/vkbd/%d", dompath, info->devid); - libxl_path = GCSPRINTF("%s/device/vkbd/%d", + devpath = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VKBD), + info->devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VKBD), info->devid); info->backend = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/backend", libxl_path), @@ -165,7 +168,7 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkbd") LIBXL_DEFINE_DEVICE_LIST(vkb) LIBXL_DEFINE_DEVICE_REMOVE(vkb) -DEFINE_DEVICE_TYPE_STRUCT_X(vkb, vkb, vkbd, +DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD, .skip_attach = 1, .dm_needed = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed, .from_xenstore = (device_from_xenstore_fn_t)libxl__vkb_from_xenstore diff --git a/tools/libxl/libxl_vsnd.c b/tools/libxl/libxl_vsnd.c index 0e7b29c..f81a9e2 100644 --- a/tools/libxl/libxl_vsnd.c +++ b/tools/libxl/libxl_vsnd.c @@ -573,11 +573,14 @@ int libxl_device_vsnd_getinfo(libxl_ctx *ctx, uint32_t domid, dompath = libxl__xs_get_dompath(gc, domid); info->devid = vsnd->devid; - devpath = GCSPRINTF("%s/device/%s/%d", dompath, libxl__vsnd_devtype.entry, + devpath = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string( + LIBXL__DEVICE_KIND_VSND), info->devid); libxl_path = GCSPRINTF("%s/device/%s/%d", libxl__xs_libxl_path(gc, domid), - libxl__vsnd_devtype.entry, info->devid); + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VSND), + info->devid); info->backend = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/backend", libxl_path), NULL); @@ -644,7 +647,7 @@ LIBXL_DEFINE_DEVICE_REMOVE(vsnd) static LIBXL_DEFINE_UPDATE_DEVID(vsnd, "vsnd") LIBXL_DEFINE_DEVICE_LIST(vsnd) -DEFINE_DEVICE_TYPE_STRUCT(vsnd, +DEFINE_DEVICE_TYPE_STRUCT(vsnd, VSND, .update_config = (device_update_config_fn_t) libxl__update_config_vsnd, .from_xenstore = (device_from_xenstore_fn_t) libxl__vsnd_from_xenstore, .set_xenstore_config = (device_set_xenstore_config_fn_t) diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c index 3f0c563..c645074 100644 --- a/tools/libxl/libxl_vtpm.c +++ b/tools/libxl/libxl_vtpm.c @@ -118,9 +118,13 @@ int libxl_device_vtpm_getinfo(libxl_ctx *ctx, dompath = libxl__xs_get_dompath(gc, domid); vtpminfo->devid = vtpm->devid; - vtpmpath = GCSPRINTF("%s/device/vtpm/%d", dompath, vtpminfo->devid); - libxl_path = GCSPRINTF("%s/device/vtpm/%d", - libxl__xs_libxl_path(gc, domid), vtpminfo->devid); + vtpmpath = GCSPRINTF("%s/device/%s/%d", dompath, + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VTPM), + vtpminfo->devid); + libxl_path = GCSPRINTF("%s/device/%s/%d", + libxl__xs_libxl_path(gc, domid), + libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VTPM), + vtpminfo->devid); vtpminfo->backend = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/backend", libxl_path), NULL); if (!vtpminfo->backend) { @@ -244,7 +248,7 @@ static LIBXL_DEFINE_DEVICES_ADD(vtpm) LIBXL_DEFINE_DEVICE_REMOVE(vtpm) LIBXL_DEFINE_DEVICE_LIST(vtpm) -DEFINE_DEVICE_TYPE_STRUCT(vtpm, +DEFINE_DEVICE_TYPE_STRUCT(vtpm, VTPM, .update_config = libxl_device_vtpm_update_config, .from_xenstore = (device_from_xenstore_fn_t)libxl__vtpm_from_xenstore, .set_xenstore_config = (device_set_xenstore_config_fn_t)