debuggers.hg

view tools/libxl/libxl_blktap2.c @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents 4ed9f9218620
children
line source
1 /*
2 * Copyright (C) 2010 Advanced Micro Devices
3 * Author Christoph Egger <Christoph.Egger@amd.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation; version 2.1 only.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 */
15 #include "libxl.h"
16 #include "libxl_osdeps.h"
17 #include "libxl_internal.h"
19 #include "tap-ctl.h"
21 int libxl__blktap_enabled(libxl__gc *gc)
22 {
23 const char *msg;
24 return !tap_ctl_check(&msg);
25 }
27 const char *libxl__blktap_devpath(libxl__gc *gc,
28 const char *disk,
29 libxl_disk_phystype phystype)
30 {
31 const char *type;
32 char *params, *devname = NULL;
33 int minor, err;
35 type = libxl__device_disk_string_of_phystype(phystype);
36 minor = tap_ctl_find_minor(type, disk);
37 if (minor >= 0) {
38 devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor);
39 if (devname)
40 return devname;
41 }
43 params = libxl__sprintf(gc, "%s:%s", type, disk);
44 err = tap_ctl_create(params, &devname);
45 if (!err) {
46 libxl__ptr_add(gc, devname);
47 return devname;
48 }
50 return NULL;
51 }