All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 8 of 9] libxl: add function to attach/detach a disk to/from the local VM
Date: Mon, 12 Jul 2010 15:01:44 +0100	[thread overview]
Message-ID: <769e3bc13a6b5b67f159.1278943304@localhost.localdomain> (raw)
In-Reply-To: <patchbomb.1278943296@localhost.localdomain>

Useful if you need to read a guest filesystem (e.g. pygrub).

I'm not overly thrilled with the implementation WRT tap interfaces,
particularly WRT to detach. I was unable to find a way to get at the
paramters necessary to call tap_ctl_destroy so I assumed for now it
that is OK to assume that the tap device is going to be wanted for the
actual domain at some point in the immediate future and hence there is
no pressing need to destroy it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 2d4475143f70 -r 769e3bc13a6b tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Mon Jul 12 14:56:37 2010 +0100
+++ b/tools/libxl/libxl.c	Mon Jul 12 14:56:37 2010 +0100
@@ -1425,6 +1425,48 @@
     return libxl_device_del(ctx, &device, wait);
 }
 
+const char * libxl_device_disk_local_attach(struct libxl_ctx *ctx, libxl_device_disk *disk)
+{
+    char *dev = NULL;
+    int phystype = disk->phystype;
+    switch (phystype) {
+        case PHYSTYPE_PHY: {
+            fprintf(stderr, "attaching PHY disk %s to domain 0\n", disk->physpath);
+            dev = disk->physpath;
+            break;
+        }
+        case PHYSTYPE_FILE:
+            /* let's pretend is tap:aio for the moment */
+            phystype = PHYSTYPE_AIO;
+        case PHYSTYPE_AIO: case PHYSTYPE_QCOW: case PHYSTYPE_QCOW2: case PHYSTYPE_VHD: {
+            const char *msg;
+            if (!tap_ctl_check(&msg)) {
+                const char *type = device_disk_string_of_phystype(phystype);
+                dev = get_blktap2_device(ctx, disk->physpath, type);
+                if (!dev)
+                    dev = make_blktap2_device(ctx, disk->physpath, type);
+            }
+            break;
+        }
+        default:
+            XL_LOG(ctx, XL_LOG_ERROR, "unrecognized disk physical type: %d\n", phystype);
+            break;
+    }
+    return dev;
+}
+
+int libxl_device_disk_local_detach(struct libxl_ctx *ctx, libxl_device_disk *disk)
+{
+    /* Nothing to do for PHYSTYPE_PHY. */
+
+    /*
+     * For other device types assume that the blktap2 process is
+     * needed by the soon to be started domain and do nothing.
+     */
+
+    return 0;
+}
+
 /******************************************************************************/
 int libxl_device_nic_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic)
 {
diff -r 2d4475143f70 -r 769e3bc13a6b tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Mon Jul 12 14:56:37 2010 +0100
+++ b/tools/libxl/libxl.h	Mon Jul 12 14:56:37 2010 +0100
@@ -423,6 +423,12 @@
                               libxl_device_disk *disk, libxl_diskinfo *diskinfo);
 int libxl_cdrom_insert(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
 
+/*
+ * Make a disk available in this domain. Returns path to a device.
+ */
+const char * libxl_device_disk_local_attach(struct libxl_ctx *ctx, libxl_device_disk *disk);
+int libxl_device_disk_local_detach(struct libxl_ctx *ctx, libxl_device_disk *disk);
+
 typedef struct {
     char *backend;
     uint32_t backend_id;

  parent reply	other threads:[~2010-07-12 14:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-12 14:01 [PATCH 0 of 9] libxl/xl: support for domain 0 bootloader (e.g. pygrub) Ian Campbell
2010-07-12 14:01 ` [PATCH 1 of 9] pygrub: introduce easier to parse output format Ian Campbell
2010-07-12 14:01 ` [PATCH 2 of 9] xenconsole: do not exit if a pty device is missing Ian Campbell
2010-07-12 14:01 ` [PATCH 3 of 9] libxl: add printf attribute to libxl_xs_write and fixup resulting warnings Ian Campbell
2010-07-12 14:01 ` [PATCH 4 of 9] libxl: add libxl_strdup convenience function Ian Campbell
2010-07-12 14:01 ` [PATCH 5 of 9] libxl: fix typo Ian Campbell
2010-07-12 14:01 ` [PATCH 6 of 9] libxl/xl: exec xenconsole in current process, defer decision to fork to caller Ian Campbell
2010-07-12 14:01 ` [PATCH 7 of 9] libxl: support mapping files rather than carrying paths around Ian Campbell
2010-07-12 14:01 ` Ian Campbell [this message]
2010-07-12 14:01 ` [PATCH 9 of 9] libxl/xl: support running bootloader (e.g. pygrub) in domain 0 Ian Campbell
2010-07-13 18:23 ` [PATCH 0 of 9] libxl/xl: support for domain 0 bootloader (e.g. pygrub) Ian Jackson
2010-07-14  1:24   ` Zhigang Wang

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=769e3bc13a6b5b67f159.1278943304@localhost.localdomain \
    --to=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.