From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xen.org
Cc: Christoph Egger <Christoph.Egger@amd.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v4] hotplug/NetBSD: check type of file to attach from params
Date: Tue, 14 Aug 2012 19:09:59 +0100 [thread overview]
Message-ID: <1344967799-6646-1-git-send-email-roger.pau@citrix.com> (raw)
xend used to set the xenbus backend entry "type" to either "phy" or
"file", but now libxl sets it to "phy" for both file and block device.
We have to manually check for the type of the "param" field in order
to detect if we are trying to attach a file or a block device.
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
Changes since v3:
* Add $xparams (that contains the path to the disk file) to the error
message.
Changes since v2:
* Better error messages.
* Check if params is empty.
* Replace xenstore_write with xenstore-write in error function.
* Add quotation marks to xparams when testing.
Changes since v1:
* Check that file is either a block special file or a regular file
and report error otherwise.
---
tools/hotplug/NetBSD/block | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/hotplug/NetBSD/block b/tools/hotplug/NetBSD/block
index cf5ff3a..f849fe4 100644
--- a/tools/hotplug/NetBSD/block
+++ b/tools/hotplug/NetBSD/block
@@ -12,15 +12,24 @@ export PATH
error() {
echo "$@" >&2
- xenstore_write $xpath/hotplug-status error
+ xenstore-write $xpath/hotplug-status error
exit 1
}
xpath=$1
xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
xparams=$(xenstore-read "$xpath/params")
+if [ -b "$xparams" ]; then
+ xtype="phy"
+elif [ -f "$xparams" ]; then
+ xtype="file"
+elif [ -z "$xparams" ]; then
+ error "$xpath/params is empty, unable to attach block device."
+else
+ error "$xparams is not a valid file type to use as block device." \
+ "Only block and regular image files accepted."
+fi
case $xstatus in
6)
--
1.7.7.5 (Apple Git-26)
next reply other threads:[~2012-08-14 18:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-14 18:09 Roger Pau Monne [this message]
2012-08-15 8:42 ` [PATCH v4] hotplug/NetBSD: check type of file to attach from params Christoph Egger
2012-08-17 8:13 ` Ian Campbell
2012-08-17 8:25 ` Christoph Egger
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=1344967799-6646-1-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=Christoph.Egger@amd.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).