WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 3 of 6] xenbackendd: pass type of block device to

To: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 3 of 6] xenbackendd: pass type of block device to hotplug script
From: Christoph Egger <Christoph.Egger@xxxxxxx>
Date: Thu, 22 Sep 2011 16:07:49 +0200
Cc: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 22 Sep 2011 07:11:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1316698516.23371.70.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1316692867@loki> <2d77cbdc816bc943e9e6.1316692870@loki> <1316698516.23371.70.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; NetBSD amd64; en-US; rv:1.9.2.17) Gecko/20110523 Lightning/1.0b3pre Thunderbird/3.1.10
On 09/22/11 15:35, Ian Campbell wrote:
On Thu, 2011-09-22 at 13:01 +0100, Roger Pau Monne wrote:
# HG changeset patch
# User Roger Pau Monne<roger.pau@xxxxxxxxxxxxx>
# Date 1316692489 -7200
# Node ID 2d77cbdc816bc943e9e69ecca34ae7157079045a
# Parent  1d3830f8a7306088b49d5732b5e88a73c2bc0315
xenbackendd: pass type of block device to hotplug script

Pass the type of block device to attach to the block script instead of reading 
it from xenstore, since new Xen versions don't make a difference between a 
block device or an image.

Signed-off-by: Roger Pau Monne<roger.pau@xxxxxxxxxxxxx>

I've not got any problem with this one, but I don't think my ACK is
worth much since it's NetBSD and I'm not really qualified, neverless:

Acked-by: Ian Campbell<ian.campbell@xxxxxxxxxx>

Acked-by: Christoph Egger <Christoph.Egger@xxxxxxx>


diff -r 1d3830f8a730 -r 2d77cbdc816b tools/hotplug/NetBSD/block
--- a/tools/hotplug/NetBSD/block        Thu Sep 22 13:54:42 2011 +0200
+++ b/tools/hotplug/NetBSD/block        Thu Sep 22 13:54:49 2011 +0200
@@ -19,7 +19,7 @@ error() {

  xpath=$1
  xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
+xtype=$3
  xparams=$(xenstore-read "$xpath/params")

  case $xstatus in
diff -r 1d3830f8a730 -r 2d77cbdc816b tools/xenbackendd/xenbackendd.c
--- a/tools/xenbackendd/xenbackendd.c   Thu Sep 22 13:54:42 2011 +0200
+++ b/tools/xenbackendd/xenbackendd.c   Thu Sep 22 13:54:49 2011 +0200
@@ -89,15 +89,15 @@ dodebug(const char *fmt, ...)
  }

  static void
-doexec(const char *cmd, const char *arg1, const char *arg2)
+doexec(const char *cmd, const char *arg1, const char *arg2, const char *arg3)
  {
-       dodebug("exec %s %s %s", cmd, arg1, arg2);
+       dodebug("exec %s %s %s %s", cmd, arg1, arg2, arg3);
        switch(vfork()) {
        case -1:
                dolog(LOG_ERR, "can't vfork: %s", strerror(errno));
                break;
        case 0:
-               execl(cmd, cmd, arg1, arg2, NULL);
+               execl(cmd, cmd, arg1, arg2, arg3, NULL);
                dolog(LOG_ERR, "can't exec %s: %s", cmd, strerror(errno));
                exit(EXIT_FAILURE);
                /* NOTREACHED */
@@ -145,11 +145,14 @@ xen_setup(void)
  int
  main(int argc, char * const argv[])
  {
+       struct stat stab;
        char **vec;
        unsigned int num;
        char *s;
        int state;
        char *sstate;
+       char *stype;
+       char *params;
        char *p;
        char buf[80];
        int type;
@@ -297,11 +300,38 @@ main(int argc, char * const argv[])
                                    strerror(errno));
                                goto next2;
                        }
-                       doexec(s, vec[XS_WATCH_PATH], sstate);
+                       doexec(s, vec[XS_WATCH_PATH], sstate, NULL);
                        break;

                case DEVTYPE_VBD:
-                       doexec(vbd_script, vec[XS_WATCH_PATH], sstate);
+                       /* check if given file is a block device or a raw image 
*/
+                       snprintf(buf, sizeof(buf), "%s/params", 
vec[XS_WATCH_PATH]);
+                       params = xs_read(xs, XBT_NULL, buf, 0);
+                       if(params == NULL) {
+                               dolog(LOG_ERR,
+                                       "Failed to read %s (%s)", buf, 
strerror(errno));
+                               goto next2;
+                       }
+                       if (stat(params,&stab)<  0) {
+                               dolog(LOG_ERR,
+                                       "Failed to get info about %s (%s)", 
params,
+                                       strerror(errno));
+                               goto next3;
+                       }
+                       stype = NULL;
+                       if (S_ISBLK(stab.st_mode))
+                               stype = "phy";
+                       if (S_ISREG(stab.st_mode))
+                               stype = "file";
+                       if (stype == NULL) {
+                               dolog(LOG_ERR,
+                                       "Failed to attach %s (not a block device or 
raw image)",
+                                       params, strerror(errno));
+                               goto next3;
+                       }
+                       doexec(vbd_script, vec[XS_WATCH_PATH], sstate, stype);
+next3:
+                       free(params);
                        break;

                default:



--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>