From: Roger Pau Monne <roger.pau@entel.upc.edu>
To: xen-devel@lists.xensource.com
Subject: [PATCH 3 of 9] libxl: add support for image files for NetBSD
Date: Fri, 14 Oct 2011 15:35:35 +0200 [thread overview]
Message-ID: <0865f90beac01012dd0f.1318599335@loki> (raw)
In-Reply-To: <patchbomb.1318599332@loki>
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID 0865f90beac01012dd0ff4a86b07d8fb62575163
# Parent 873e4a1309ce5da0305611ce2e2b460df052019b
libxl: add support for image files for NetBSD
Created a helper function to detect if the OS is capable of using image files as phy backends. Create two OS specific files, and changed the Makefile to choose the correct one at compile time.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r 873e4a1309ce -r 0865f90beac0 tools/libxl/Makefile
--- a/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200
@@ -31,6 +31,8 @@ LIBXL_OBJS-y += libxl_noblktap2.o
endif
LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o
LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o
+LIBXL_OBJS-$(CONFIG_NetBSD) += libxl_phybackend.o
+LIBXL_OBJS-$(CONFIG_Linux) += libxl_nophybackend.o
LIBXL_LIBS += -lyajl
diff -r 873e4a1309ce -r 0865f90beac0 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
@@ -138,15 +138,14 @@ static int disk_try_backend(disk_try_bac
a->disk->format == LIBXL_DISK_FORMAT_EMPTY)) {
goto bad_format;
}
- if (a->disk->format != LIBXL_DISK_FORMAT_EMPTY &&
- !S_ISBLK(a->stab.st_mode)) {
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
- " unsuitable as phys path not a block device",
- a->disk->vdev);
- return 0;
- }
- return backend;
+ if (try_phy_backend(a->stab.st_mode))
+ return backend;
+
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
+ " unsuitable as phys path not a block device",
+ a->disk->vdev);
+ return 0;
case LIBXL_DISK_BACKEND_TAP:
if (!libxl__blktap_enabled(a->gc)) {
diff -r 873e4a1309ce -r 0865f90beac0 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
@@ -247,6 +247,9 @@ _hidden int libxl__device_destroy(libxl_
_hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force);
_hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
+/* OS dependant helper function */
+_hidden int try_phy_backend(mode_t st_mode);
+
/* from libxl_pci */
_hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting);
diff -r 873e4a1309ce -r 0865f90beac0 tools/libxl/libxl_nophybackend.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_nophybackend.c Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011
+ * Author Roger Pau Monne <roger.pau@entel.upc.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include <sys/stat.h>
+
+#include "libxl_internal.h"
+
+int try_phy_backend(mode_t st_mode)
+{
+ if (!S_ISBLK(st_mode)) {
+ return 0;
+ }
+
+ return 1;
+}
diff -r 873e4a1309ce -r 0865f90beac0 tools/libxl/libxl_phybackend.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_phybackend.c Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011
+ * Author Roger Pau Monne <roger.pau@entel.upc.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include <sys/stat.h>
+
+#include "libxl_internal.h"
+
+int try_phy_backend(mode_t st_mode)
+{
+ if (S_ISREG(st_mode) || S_ISBLK(st_mode))
+ return 1;
+
+ return 0;
+}
next prev parent reply other threads:[~2011-10-14 13:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-14 13:35 [PATCH 0 of 9] Call hotplug scripts from libxl for NetBSD Roger Pau Monne
2011-10-14 13:35 ` [PATCH 1 of 9] xenbackendd: pass type of block device to hotplug script Roger Pau Monne
2011-10-14 13:35 ` [PATCH 2 of 9] libxl: fix for libxl not waiting for devices to disconnect Roger Pau Monne
2011-10-14 13:35 ` Roger Pau Monne [this message]
2011-10-14 13:35 ` [PATCH 4 of 9] libxl: add libxl__forkexec to execute hotplug scripts Roger Pau Monne
2011-10-14 13:35 ` [PATCH 5 of 9] libxl: wait for devices to initialize upon addition to the domain Roger Pau Monne
2011-10-14 13:35 ` [PATCH 6 of 9] libxl: execute hotplug scripts directly from libxl Roger Pau Monne
2011-10-14 13:35 ` [PATCH 7 of 9] hotplug NetBSD: detach devices when state is 5 or 6 Roger Pau Monne
2011-10-14 13:35 ` [PATCH 8 of 9] hotplug: remove debug messages from NetBSD hotplug scripts Roger Pau Monne
2011-10-14 13:35 ` [PATCH 9 of 9] rc.d NetBSD: don't start xenbackendd by default, only when xend needs it Roger Pau Monne
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=0865f90beac01012dd0f.1318599335@loki \
--to=roger.pau@entel.upc.edu \
--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.