debuggers.hg

view tools/libxl/libxl_blktap2.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 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 }