direct-io.hg

changeset 1433:2716b44c7f49

bitkeeper revision 1.936 (40c09331NirwCvM2egwMlUy301iNmg)

Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xeno
author kaf24@scramble.cl.cam.ac.uk
date Fri Jun 04 15:20:17 2004 +0000 (2004-06-04)
parents 0a5f9f92c571 2629c9faf1ad
children 833ef5f19355
files tools/examples/xc_dom_create.py tools/xend/lib/blkif.py tools/xend/lib/domain_controller.h tools/xend/lib/main.py tools/xend/lib/manager.py tools/xend/lib/netif.py tools/xend/lib/utils.c xen/include/hypervisor-ifs/hypervisor-if.h
line diff
     1.1 --- a/tools/examples/xc_dom_create.py	Fri Jun 04 14:07:21 2004 +0000
     1.2 +++ b/tools/examples/xc_dom_create.py	Fri Jun 04 15:20:17 2004 +0000
     1.3 @@ -91,6 +91,7 @@ vbd_list = []; cmdline_ip = ''; cmdline_
     1.4  pci_device_list = []; console_port = -1
     1.5  auto_console = False
     1.6  dontstart = False
     1.7 +flags = 0
     1.8  
     1.9  ##### Determine location of defaults file
    1.10  #####
     2.1 --- a/tools/xend/lib/blkif.py	Fri Jun 04 14:07:21 2004 +0000
     2.2 +++ b/tools/xend/lib/blkif.py	Fri Jun 04 15:20:17 2004 +0000
     2.3 @@ -43,19 +43,29 @@ def backend_rx_rsp(port, msg):
     2.4          rsp = { 'success': True }
     2.5          xend.main.send_management_response(rsp, xend.blkif.pendaddr)
     2.6      elif subtype == CMSG_BLKIF_BE_CONNECT:
     2.7 -        (dom,hnd,evtchn,frame,st) = struct.unpack("IIILI", msg.get_payload())
     2.8 +        pl = msg.get_payload()
     2.9 +        (dom, hnd, frame, evtchn, st) = (pl['domid'], pl['blkif_handle'],
    2.10 +                                         pl['shmem_frame'], pl['evtchn'],
    2.11 +                                         pl['status'])
    2.12          blkif = interface.list[xend.main.port_from_dom(dom).local_port]
    2.13 -        msg = xend.utils.message(CMSG_BLKIF_FE, \
    2.14 -                                 CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED, 0)
    2.15 -        msg.append_payload(struct.pack("III",0,2,blkif.evtchn['port2']))
    2.16 +        msg = xend.utils.message(CMSG_BLKIF_FE,
    2.17 +                                 CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED, 0,
    2.18 +                                 { 'handle' : 0, 'status' : 2,
    2.19 +                                   'evtchn' : blkif.evtchn['port2'] })
    2.20          blkif.ctrlif_tx_req(xend.main.port_list[blkif.key], msg)
    2.21      elif subtype == CMSG_BLKIF_BE_VBD_CREATE:
    2.22 -        (dom,hnd,vdev,ro,st) = struct.unpack("IIHII", msg.get_payload())
    2.23 +        pl = msg.get_payload()
    2.24 +        (dom, hnd, vdev, ro, st) = (pl['domid'], pl['blkif_handle'],
    2.25 +                                    pl['vdevice'], pl['readonly'],
    2.26 +                                    pl['status'])
    2.27          blkif = interface.list[xend.main.port_from_dom(dom).local_port]
    2.28          (pdev, start_sect, nr_sect, readonly) = blkif.devices[vdev]
    2.29 -        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW, 0)
    2.30 -        msg.append_payload(struct.pack("IIHHHQQI",dom,0,vdev,0, \
    2.31 -                                       pdev,start_sect,nr_sect,0))
    2.32 +        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW, 0,
    2.33 +                                 { 'domid' : dom, 'blkif_handle' : 0,
    2.34 +                                   'vdevice' : vdev,
    2.35 +                                   'extent.sector_start' : start_sect,
    2.36 +                                   'extent.sector.length' : nr_sect,
    2.37 +                                   'extent.device' : pdev })
    2.38          backend_tx_req(msg)
    2.39      elif subtype == CMSG_BLKIF_BE_VBD_GROW:
    2.40          rsp = { 'success': True }
    2.41 @@ -83,8 +93,8 @@ class interface:
    2.42          self.devices = {}
    2.43          self.pendmsg = None
    2.44          interface.list[key] = self
    2.45 -        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CREATE, 0)
    2.46 -        msg.append_payload(struct.pack("III",dom,0,0))
    2.47 +        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CREATE, 0,
    2.48 +                                 { 'domid' : dom, 'blkif_handle' : 0 })
    2.49          xend.blkif.pendaddr = xend.main.mgmt_req_addr
    2.50          backend_tx_req(msg)
    2.51  
    2.52 @@ -93,8 +103,9 @@ class interface:
    2.53          if self.devices.has_key(vdev):
    2.54              return False
    2.55          self.devices[vdev] = (pdev, start_sect, nr_sect, readonly)
    2.56 -        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE, 0)
    2.57 -        msg.append_payload(struct.pack("IIHII",self.dom,0,vdev,readonly,0))
    2.58 +        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE, 0,
    2.59 +                                 { 'domid' : self.dom, 'blkif_handle' : 0,
    2.60 +                                   'vdevice' : vdev, 'readonly' : readonly })
    2.61          xend.blkif.pendaddr = xend.main.mgmt_req_addr
    2.62          backend_tx_req(msg)
    2.63          return True
    2.64 @@ -103,8 +114,8 @@ class interface:
    2.65      # Completely destroy this interface.
    2.66      def destroy(self):
    2.67          del interface.list[self.key]
    2.68 -        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DESTROY, 0)
    2.69 -        msg.append_payload(struct.pack("III",self.dom,0,0))
    2.70 +        msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DESTROY, 0,
    2.71 +                                 { 'domid' : self.dom, 'blkif_handle' : 0 })
    2.72          backend_tx_req(msg)        
    2.73  
    2.74  
    2.75 @@ -128,16 +139,19 @@ class interface:
    2.76          port.write_response(msg)
    2.77          subtype = (msg.get_header())['subtype']
    2.78          if subtype == CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED:
    2.79 -            msg = xend.utils.message(CMSG_BLKIF_FE, \
    2.80 -                                     CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED, 0)
    2.81 -            msg.append_payload(struct.pack("III",0,1,0))
    2.82 +            msg = xend.utils.message(CMSG_BLKIF_FE,
    2.83 +                                     CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED,
    2.84 +                                     0,
    2.85 +                                     { 'handle' : 0, 'status' : 1 })
    2.86              self.ctrlif_tx_req(port, msg)
    2.87          elif subtype == CMSG_BLKIF_FE_INTERFACE_CONNECT:
    2.88 -            (hnd,frame) = struct.unpack("IL", msg.get_payload())
    2.89 +            pl = msg.get_payload()
    2.90 +            (hnd, frame) = (pl['handle'], pl['shmem_frame'])
    2.91              xc = Xc.new()
    2.92              self.evtchn = xc.evtchn_bind_interdomain(dom1=0,dom2=self.dom)
    2.93 -            msg = xend.utils.message(CMSG_BLKIF_BE, \
    2.94 -                                     CMSG_BLKIF_BE_CONNECT, 0)
    2.95 -            msg.append_payload(struct.pack("IIILI",self.dom,0, \
    2.96 -                                           self.evtchn['port1'],frame,0))
    2.97 +            msg = xend.utils.message(CMSG_BLKIF_BE,
    2.98 +                                     CMSG_BLKIF_BE_CONNECT, 0,
    2.99 +                                     { 'domid' : self.dom, 'blkif_handle' : 0,
   2.100 +                                       'shmem_frame' : frame,
   2.101 +                                       'evtchn' : self.evtchn['port1'] })
   2.102              backend_tx_req(msg)
     3.1 --- a/tools/xend/lib/domain_controller.h	Fri Jun 04 14:07:21 2004 +0000
     3.2 +++ b/tools/xend/lib/domain_controller.h	Fri Jun 04 15:20:17 2004 +0000
     3.3 @@ -22,8 +22,10 @@
     3.4  
     3.5  typedef struct {
     3.6      BASIC_START_INFO;
     3.7 -    unsigned int domain_controller_evtchn;
     3.8 -} extended_start_info_t;
     3.9 +    u16 domain_controller_evtchn; /* 320 */
    3.10 +} PACKED extended_start_info_t; /* 322 bytes */
    3.11 +#define SIF_BLK_BE_DOMAIN (1<<4)  /* Is this a block backend domain? */
    3.12 +#define SIF_NET_BE_DOMAIN (1<<5)  /* Is this a net backend domain? */
    3.13  
    3.14  
    3.15  /*
    3.16 @@ -31,23 +33,23 @@ typedef struct {
    3.17   */
    3.18  
    3.19  typedef struct {
    3.20 -    u8 type;     /* echoed in response */
    3.21 -    u8 subtype;  /* echoed in response */
    3.22 -    u8 id;       /* echoed in response */
    3.23 -    u8 length;   /* number of bytes in 'msg' */
    3.24 -    unsigned char msg[60]; /* type-specific message data */
    3.25 -} control_msg_t;
    3.26 +    u8 type;     /*  0: echoed in response */
    3.27 +    u8 subtype;  /*  1: echoed in response */
    3.28 +    u8 id;       /*  2: echoed in response */
    3.29 +    u8 length;   /*  3: number of bytes in 'msg' */
    3.30 +    u8 msg[60];  /*  4: type-specific message data */
    3.31 +} PACKED control_msg_t; /* 64 bytes */
    3.32  
    3.33  #define CONTROL_RING_SIZE 8
    3.34 -typedef unsigned int CONTROL_RING_IDX;
    3.35 +typedef u32 CONTROL_RING_IDX;
    3.36  #define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1))
    3.37  
    3.38  typedef struct {
    3.39 -    control_msg_t tx_ring[CONTROL_RING_SIZE]; /* guest-OS -> controller */
    3.40 -    control_msg_t rx_ring[CONTROL_RING_SIZE]; /* controller -> guest-OS */
    3.41 -    CONTROL_RING_IDX tx_req_prod, tx_resp_prod;
    3.42 -    CONTROL_RING_IDX rx_req_prod, rx_resp_prod;
    3.43 -} control_if_t;
    3.44 +    control_msg_t tx_ring[CONTROL_RING_SIZE];   /*    0: guest -> controller */
    3.45 +    control_msg_t rx_ring[CONTROL_RING_SIZE];   /*  512: controller -> guest */
    3.46 +    CONTROL_RING_IDX tx_req_prod, tx_resp_prod; /* 1024, 1028 */
    3.47 +    CONTROL_RING_IDX rx_req_prod, rx_resp_prod; /* 1032, 1036 */
    3.48 +} PACKED control_if_t; /* 1040 bytes */
    3.49  
    3.50  /*
    3.51   * Top-level command types.
    3.52 @@ -97,10 +99,10 @@ typedef struct {
    3.53  #define BLKIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
    3.54  #define BLKIF_INTERFACE_STATUS_CONNECTED    2 /* Exists and is connected.    */
    3.55  typedef struct {
    3.56 -    unsigned int handle;
    3.57 -    unsigned int status;
    3.58 -    unsigned int evtchn; /* status == BLKIF_INTERFACE_STATUS_CONNECTED */
    3.59 -} blkif_fe_interface_status_changed_t;
    3.60 +    u32 handle; /*  0 */
    3.61 +    u32 status; /*  4 */
    3.62 +    u16 evtchn; /*  8: (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */
    3.63 +} PACKED blkif_fe_interface_status_changed_t; /* 10 bytes */
    3.64  
    3.65  /*
    3.66   * CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED:
    3.67 @@ -115,14 +117,14 @@ typedef struct {
    3.68  #define BLKIF_DRIVER_STATUS_UP     1
    3.69  typedef struct {
    3.70      /* IN */
    3.71 -    unsigned int status; /* BLKIF_DRIVER_STATUS_??? */
    3.72 +    u32 status;        /*  0: BLKIF_DRIVER_STATUS_??? */
    3.73      /* OUT */
    3.74      /*
    3.75       * Tells driver how many interfaces it should expect to immediately
    3.76       * receive notifications about.
    3.77       */
    3.78 -    unsigned int nr_interfaces;
    3.79 -} blkif_fe_driver_status_changed_t;
    3.80 +    u32 nr_interfaces; /*  4 */
    3.81 +} PACKED blkif_fe_driver_status_changed_t; /* 8 bytes */
    3.82  
    3.83  /*
    3.84   * CMSG_BLKIF_FE_INTERFACE_CONNECT:
    3.85 @@ -130,9 +132,11 @@ typedef struct {
    3.86   *  STATUS_CONNECTED message.
    3.87   */
    3.88  typedef struct {
    3.89 -    unsigned int  handle;
    3.90 -    unsigned long shmem_frame;
    3.91 -} blkif_fe_interface_connect_t;
    3.92 +    u32      handle;      /*  0 */
    3.93 +    u32      __pad;
    3.94 +    memory_t shmem_frame; /*  8 */
    3.95 +    MEMORY_PADDING;
    3.96 +} PACKED blkif_fe_interface_connect_t; /* 16 bytes */
    3.97  
    3.98  /*
    3.99   * CMSG_BLKIF_FE_INTERFACE_DISCONNECT:
   3.100 @@ -140,8 +144,8 @@ typedef struct {
   3.101   *  STATUS_DISCONNECTED message.
   3.102   */
   3.103  typedef struct {
   3.104 -    unsigned int handle;
   3.105 -} blkif_fe_interface_disconnect_t;
   3.106 +    u32 handle; /*  0 */
   3.107 +} PACKED blkif_fe_interface_disconnect_t; /* 4 bytes */
   3.108  
   3.109  
   3.110  /******************************************************************************
   3.111 @@ -166,10 +170,11 @@ typedef struct {
   3.112   */
   3.113  
   3.114  typedef struct {
   3.115 -    blkif_pdev_t   device;
   3.116 -    blkif_sector_t sector_start;
   3.117 -    blkif_sector_t sector_length;
   3.118 -} blkif_extent_t;
   3.119 +    blkif_sector_t sector_start;   /*  0 */
   3.120 +    blkif_sector_t sector_length;  /*  8 */
   3.121 +    blkif_pdev_t   device;         /* 16 */
   3.122 +    u16            __pad;          /* 18 */
   3.123 +} PACKED blkif_extent_t; /* 20 bytes */
   3.124  
   3.125  /* Non-specific 'okay' return. */
   3.126  #define BLKIF_BE_STATUS_OKAY                0
   3.127 @@ -206,11 +211,11 @@ typedef struct {
   3.128   */
   3.129  typedef struct { 
   3.130      /* IN */
   3.131 -    domid_t        domid;             /* Domain attached to new interface.   */
   3.132 -    unsigned int   blkif_handle;      /* Domain-specific interface handle.   */
   3.133 +    domid_t    domid;         /*  0: Domain attached to new interface.   */
   3.134 +    u32        blkif_handle;  /*  4: Domain-specific interface handle.   */
   3.135      /* OUT */
   3.136 -    unsigned int   status;
   3.137 -} blkif_be_create_t; 
   3.138 +    u32        status;        /*  8 */
   3.139 +} PACKED blkif_be_create_t; /* 12 bytes */
   3.140  
   3.141  /*
   3.142   * CMSG_BLKIF_BE_DESTROY:
   3.143 @@ -220,11 +225,11 @@ typedef struct {
   3.144   */
   3.145  typedef struct { 
   3.146      /* IN */
   3.147 -    domid_t        domid;             /* Identify interface to be destroyed. */
   3.148 -    unsigned int   blkif_handle;      /* ...ditto...                         */
   3.149 +    domid_t    domid;         /*  0: Identify interface to be destroyed. */
   3.150 +    u32        blkif_handle;  /*  4: ...ditto...                         */
   3.151      /* OUT */
   3.152 -    unsigned int   status;
   3.153 -} blkif_be_destroy_t; 
   3.154 +    u32        status;        /*  8 */
   3.155 +} PACKED blkif_be_destroy_t; /* 12 bytes */
   3.156  
   3.157  /*
   3.158   * CMSG_BLKIF_BE_CONNECT:
   3.159 @@ -234,13 +239,14 @@ typedef struct {
   3.160   */
   3.161  typedef struct { 
   3.162      /* IN */
   3.163 -    domid_t        domid;             /* Domain attached to new interface.   */
   3.164 -    unsigned int   blkif_handle;      /* Domain-specific interface handle.   */
   3.165 -    unsigned int   evtchn;            /* Event channel for notifications.    */
   3.166 -    unsigned long  shmem_frame;       /* Page cont. shared comms window.     */
   3.167 +    domid_t    domid;         /*  0: Domain attached to new interface.   */
   3.168 +    u32        blkif_handle;  /*  4: Domain-specific interface handle.   */
   3.169 +    memory_t   shmem_frame;   /*  8: Page cont. shared comms window.     */
   3.170 +    MEMORY_PADDING;
   3.171 +    u32        evtchn;        /* 16: Event channel for notifications.    */
   3.172      /* OUT */
   3.173 -    unsigned int   status;
   3.174 -} blkif_be_connect_t; 
   3.175 +    u32        status;        /* 20 */
   3.176 +} PACKED blkif_be_connect_t;  /* 24 bytes */
   3.177  
   3.178  /*
   3.179   * CMSG_BLKIF_BE_DISCONNECT:
   3.180 @@ -250,70 +256,66 @@ typedef struct {
   3.181   */
   3.182  typedef struct { 
   3.183      /* IN */
   3.184 -    domid_t        domid;             /* Domain attached to new interface.   */
   3.185 -    unsigned int   blkif_handle;      /* Domain-specific interface handle.   */
   3.186 +    domid_t    domid;         /*  0: Domain attached to new interface.   */
   3.187 +    u32        blkif_handle;  /*  4: Domain-specific interface handle.   */
   3.188      /* OUT */
   3.189 -    unsigned int   status;
   3.190 -} blkif_be_disconnect_t; 
   3.191 +    u32        status;        /*  8 */
   3.192 +} PACKED blkif_be_disconnect_t; /* 12 bytes */
   3.193  
   3.194  /* CMSG_BLKIF_BE_VBD_CREATE */
   3.195  typedef struct { 
   3.196      /* IN */
   3.197 -    domid_t        domid;             /* Identify blkdev interface.          */
   3.198 -    unsigned int   blkif_handle;      /* ...ditto...                         */
   3.199 -    blkif_vdev_t   vdevice;           /* Interface-specific id for this VBD. */
   3.200 -    int            readonly;          /* Non-zero -> VBD isn't writeable.    */
   3.201 +    domid_t    domid;         /*  0: Identify blkdev interface.          */
   3.202 +    u32        blkif_handle;  /*  4: ...ditto...                         */
   3.203 +    blkif_vdev_t vdevice;     /*  8: Interface-specific id for this VBD. */
   3.204 +    u16        readonly;      /* 10: Non-zero -> VBD isn't writeable.    */
   3.205      /* OUT */
   3.206 -    unsigned int   status;
   3.207 -} blkif_be_vbd_create_t; 
   3.208 +    u32        status;        /* 12 */
   3.209 +} PACKED blkif_be_vbd_create_t; /* 16 bytes */
   3.210  
   3.211  /* CMSG_BLKIF_BE_VBD_DESTROY */
   3.212  typedef struct {
   3.213      /* IN */
   3.214 -    domid_t        domid;             /* Identify blkdev interface.          */
   3.215 -    unsigned int   blkif_handle;      /* ...ditto...                         */
   3.216 -    blkif_vdev_t   vdevice;           /* Interface-specific id of the VBD.   */
   3.217 +    domid_t    domid;         /*  0: Identify blkdev interface.          */
   3.218 +    u32        blkif_handle;  /*  4: ...ditto...                         */
   3.219 +    blkif_vdev_t vdevice;     /*  8: Interface-specific id of the VBD.   */
   3.220 +    u16        __pad;         /* 10 */
   3.221      /* OUT */
   3.222 -    unsigned int   status;
   3.223 -} blkif_be_vbd_destroy_t; 
   3.224 +    u32        status;        /* 12 */
   3.225 +} PACKED blkif_be_vbd_destroy_t; /* 16 bytes */
   3.226  
   3.227  /* CMSG_BLKIF_BE_VBD_GROW */
   3.228  typedef struct { 
   3.229      /* IN */
   3.230 -    domid_t        domid;             /* Identify blkdev interface.          */
   3.231 -    unsigned int   blkif_handle;      /* ...ditto...                         */
   3.232 -    blkif_vdev_t   vdevice;           /* Interface-specific id of the VBD.   */
   3.233 -    blkif_extent_t extent;            /* Physical extent to append to VBD.   */
   3.234 +    domid_t    domid;         /*  0: Identify blkdev interface.          */
   3.235 +    u32        blkif_handle;  /*  4: ...ditto...                         */
   3.236 +    blkif_extent_t extent;    /*  8: Physical extent to append to VBD.   */
   3.237 +    blkif_vdev_t vdevice;     /* 28: Interface-specific id of the VBD.   */
   3.238 +    u16        __pad;         /* 30 */
   3.239      /* OUT */
   3.240 -    unsigned int   status;
   3.241 -} blkif_be_vbd_grow_t; 
   3.242 +    u32        status;        /* 32 */
   3.243 +} PACKED blkif_be_vbd_grow_t; /* 36 bytes */
   3.244  
   3.245  /* CMSG_BLKIF_BE_VBD_SHRINK */
   3.246  typedef struct { 
   3.247      /* IN */
   3.248 -    domid_t        domid;             /* Identify blkdev interface.          */
   3.249 -    unsigned int   blkif_handle;      /* ...ditto...                         */
   3.250 -    blkif_vdev_t   vdevice;           /* Interface-specific id of the VBD.   */
   3.251 +    domid_t    domid;         /*  0: Identify blkdev interface.          */
   3.252 +    u32        blkif_handle;  /*  4: ...ditto...                         */
   3.253 +    blkif_vdev_t vdevice;     /*  8: Interface-specific id of the VBD.   */
   3.254 +    u16        __pad;         /* 10 */
   3.255      /* OUT */
   3.256 -    unsigned int   status;
   3.257 -} blkif_be_vbd_shrink_t; 
   3.258 +    u32        status;        /* 12 */
   3.259 +} PACKED blkif_be_vbd_shrink_t; /* 16 bytes */
   3.260  
   3.261  /*
   3.262   * CMSG_BLKIF_BE_DRIVER_STATUS_CHANGED:
   3.263   *  Notify the domain controller that the back-end driver is DOWN or UP.
   3.264 - *  If the driver goes DOWN while interfaces are still UP, the domain
   3.265 + *  If the driver goes DOWN while interfaces are still UP, the controller
   3.266   *  will automatically send DOWN notifications.
   3.267   */
   3.268  typedef struct {
   3.269 -    /* IN */
   3.270 -    unsigned int status; /* BLKIF_DRIVER_STATUS_??? */
   3.271 -    /* OUT */
   3.272 -    /*
   3.273 -     * Tells driver how many interfaces it should expect to immediately
   3.274 -     * receive notifications about.
   3.275 -     */
   3.276 -    unsigned int nr_interfaces;
   3.277 -} blkif_be_driver_status_changed_t;
   3.278 +    u32        status;        /*  0: BLKIF_DRIVER_STATUS_??? */
   3.279 +} PACKED blkif_be_driver_status_changed_t; /* 4 bytes */
   3.280  
   3.281  
   3.282  /******************************************************************************
   3.283 @@ -339,11 +341,11 @@ typedef struct {
   3.284  #define NETIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
   3.285  #define NETIF_INTERFACE_STATUS_CONNECTED    2 /* Exists and is connected.    */
   3.286  typedef struct {
   3.287 -    unsigned int handle;
   3.288 -    unsigned int status;
   3.289 -    unsigned int evtchn; /* status == NETIF_INTERFACE_STATUS_CONNECTED */
   3.290 -    u8           mac[6]; /* status == NETIF_INTERFACE_STATUS_CONNECTED */
   3.291 -} netif_fe_interface_status_changed_t;
   3.292 +    u32        handle; /*  0 */
   3.293 +    u32        status; /*  4 */
   3.294 +    u16        evtchn; /*  8: status == NETIF_INTERFACE_STATUS_CONNECTED */
   3.295 +    u8         mac[6]; /* 10: status == NETIF_INTERFACE_STATUS_CONNECTED */
   3.296 +} PACKED netif_fe_interface_status_changed_t; /* 16 bytes */
   3.297  
   3.298  /*
   3.299   * CMSG_NETIF_FE_DRIVER_STATUS_CHANGED:
   3.300 @@ -358,14 +360,14 @@ typedef struct {
   3.301  #define NETIF_DRIVER_STATUS_UP     1
   3.302  typedef struct {
   3.303      /* IN */
   3.304 -    unsigned int status; /* NETIF_DRIVER_STATUS_??? */
   3.305 +    u32        status;        /*  0: NETIF_DRIVER_STATUS_??? */
   3.306      /* OUT */
   3.307      /*
   3.308       * Tells driver how many interfaces it should expect to immediately
   3.309       * receive notifications about.
   3.310       */
   3.311 -    unsigned int nr_interfaces;
   3.312 -} netif_fe_driver_status_changed_t;
   3.313 +    u32        nr_interfaces; /*  4 */
   3.314 +} PACKED netif_fe_driver_status_changed_t; /* 8 bytes */
   3.315  
   3.316  /*
   3.317   * CMSG_NETIF_FE_INTERFACE_CONNECT:
   3.318 @@ -373,10 +375,13 @@ typedef struct {
   3.319   *  STATUS_CONNECTED message.
   3.320   */
   3.321  typedef struct {
   3.322 -    unsigned int  handle;
   3.323 -    unsigned long tx_shmem_frame;
   3.324 -    unsigned long rx_shmem_frame;
   3.325 -} netif_fe_interface_connect_t;
   3.326 +    u32        handle;         /*  0 */
   3.327 +    u32        __pad;          /*  4 */
   3.328 +    memory_t   tx_shmem_frame; /*  8 */
   3.329 +    MEMORY_PADDING;
   3.330 +    memory_t   rx_shmem_frame; /* 16 */
   3.331 +    MEMORY_PADDING;
   3.332 +} PACKED netif_fe_interface_connect_t; /* 24 bytes */
   3.333  
   3.334  /*
   3.335   * CMSG_NETIF_FE_INTERFACE_DISCONNECT:
   3.336 @@ -384,8 +389,8 @@ typedef struct {
   3.337   *  STATUS_DISCONNECTED message.
   3.338   */
   3.339  typedef struct {
   3.340 -    unsigned int handle;
   3.341 -} netif_fe_interface_disconnect_t;
   3.342 +    u32        handle;        /*  0 */
   3.343 +} PACKED netif_fe_interface_disconnect_t; /* 4 bytes */
   3.344  
   3.345  
   3.346  /******************************************************************************
   3.347 @@ -434,12 +439,13 @@ typedef struct {
   3.348   */
   3.349  typedef struct { 
   3.350      /* IN */
   3.351 -    domid_t        domid;             /* Domain attached to new interface.   */
   3.352 -    unsigned int   netif_handle;      /* Domain-specific interface handle.   */
   3.353 -    u8             mac[6];
   3.354 +    domid_t    domid;         /*  0: Domain attached to new interface.   */
   3.355 +    u32        netif_handle;  /*  4: Domain-specific interface handle.   */
   3.356 +    u8         mac[6];        /*  8 */
   3.357 +    u16        __pad;         /* 14 */
   3.358      /* OUT */
   3.359 -    unsigned int   status;
   3.360 -} netif_be_create_t; 
   3.361 +    u32        status;        /* 16 */
   3.362 +} PACKED netif_be_create_t; /* 20 bytes */
   3.363  
   3.364  /*
   3.365   * CMSG_NETIF_BE_DESTROY:
   3.366 @@ -449,11 +455,11 @@ typedef struct {
   3.367   */
   3.368  typedef struct { 
   3.369      /* IN */
   3.370 -    domid_t        domid;             /* Identify interface to be destroyed. */
   3.371 -    unsigned int   netif_handle;      /* ...ditto...                         */
   3.372 +    domid_t    domid;         /*  0: Identify interface to be destroyed. */
   3.373 +    u32        netif_handle;  /*  4: ...ditto...                         */
   3.374      /* OUT */
   3.375 -    unsigned int   status;
   3.376 -} netif_be_destroy_t; 
   3.377 +    u32   status;             /*  8 */
   3.378 +} PACKED netif_be_destroy_t; /* 12 bytes */
   3.379  
   3.380  /*
   3.381   * CMSG_NETIF_BE_CONNECT:
   3.382 @@ -463,14 +469,17 @@ typedef struct {
   3.383   */
   3.384  typedef struct { 
   3.385      /* IN */
   3.386 -    domid_t        domid;             /* Domain attached to new interface.   */
   3.387 -    unsigned int   netif_handle;      /* Domain-specific interface handle.   */
   3.388 -    unsigned int   evtchn;            /* Event channel for notifications.    */
   3.389 -    unsigned long  tx_shmem_frame;    /* Page cont. tx shared comms window.  */
   3.390 -    unsigned long  rx_shmem_frame;    /* Page cont. rx shared comms window.  */
   3.391 +    domid_t    domid;          /*  0: Domain attached to new interface.   */
   3.392 +    u32        netif_handle;   /*  4: Domain-specific interface handle.   */
   3.393 +    memory_t   tx_shmem_frame; /*  8: Page cont. tx shared comms window.  */
   3.394 +    MEMORY_PADDING;
   3.395 +    memory_t   rx_shmem_frame; /* 16: Page cont. rx shared comms window.  */
   3.396 +    MEMORY_PADDING;
   3.397 +    u16        evtchn;         /* 24: Event channel for notifications.    */
   3.398 +    u16        __pad;          /* 26 */
   3.399      /* OUT */
   3.400 -    unsigned int   status;
   3.401 -} netif_be_connect_t; 
   3.402 +    u32        status;         /* 28 */
   3.403 +} PACKED netif_be_connect_t; /* 32 bytes */
   3.404  
   3.405  /*
   3.406   * CMSG_NETIF_BE_DISCONNECT:
   3.407 @@ -480,11 +489,11 @@ typedef struct {
   3.408   */
   3.409  typedef struct { 
   3.410      /* IN */
   3.411 -    domid_t        domid;             /* Domain attached to new interface.   */
   3.412 -    unsigned int   netif_handle;      /* Domain-specific interface handle.   */
   3.413 +    domid_t    domid;         /*  0: Domain attached to new interface.   */
   3.414 +    u32        netif_handle;  /*  4: Domain-specific interface handle.   */
   3.415      /* OUT */
   3.416 -    unsigned int   status;
   3.417 -} netif_be_disconnect_t; 
   3.418 +    u32        status;        /*  8 */
   3.419 +} PACKED netif_be_disconnect_t; /* 12 bytes */
   3.420  
   3.421  /*
   3.422   * CMSG_NETIF_BE_DRIVER_STATUS_CHANGED:
   3.423 @@ -493,14 +502,7 @@ typedef struct {
   3.424   *  will automatically send DOWN notifications.
   3.425   */
   3.426  typedef struct {
   3.427 -    /* IN */
   3.428 -    unsigned int status; /* NETIF_DRIVER_STATUS_??? */
   3.429 -    /* OUT */
   3.430 -    /*
   3.431 -     * Tells driver how many interfaces it should expect to immediately
   3.432 -     * receive notifications about.
   3.433 -     */
   3.434 -    unsigned int nr_interfaces;
   3.435 -} netif_be_driver_status_changed_t;
   3.436 +    u32        status;        /*  0: NETIF_DRIVER_STATUS_??? */
   3.437 +} PACKED netif_be_driver_status_changed_t; /* 4 bytes */
   3.438  
   3.439  #endif /* __DOMAIN_CONTROLLER_H__ */
     4.1 --- a/tools/xend/lib/main.py	Fri Jun 04 14:07:21 2004 +0000
     4.2 +++ b/tools/xend/lib/main.py	Fri Jun 04 15:20:17 2004 +0000
     4.3 @@ -75,6 +75,8 @@ def daemon_loop():
     4.4      notifier.bind(dom0_port.local_port)
     4.5      port_list[dom0_port.local_port] = dom0_port
     4.6  
     4.7 +    xend.netif.be_port = dom0_port
     4.8 +
     4.9      ##
    4.10      ## MAIN LOOP
    4.11      ## 
     5.1 --- a/tools/xend/lib/manager.py	Fri Jun 04 14:07:21 2004 +0000
     5.2 +++ b/tools/xend/lib/manager.py	Fri Jun 04 15:20:17 2004 +0000
     5.3 @@ -158,6 +158,7 @@ def new_network_interface(dom, handle=-1
     5.4  ##   for the network will only be accepted from this domain.
     5.5  ##
     5.6  def set_network_backend(dom):
     5.7 -    if xend.netif.be_port: xend.netif.recovery = True
     5.8 +    if xend.netif.be_port.remote_dom != 0:
     5.9 +        xend.netif.recovery = True
    5.10      xend.netif.be_port = xend.main.port_from_dom(dom)
    5.11      return { 'success' : True }
     6.1 --- a/tools/xend/lib/netif.py	Fri Jun 04 14:07:21 2004 +0000
     6.2 +++ b/tools/xend/lib/netif.py	Fri Jun 04 15:20:17 2004 +0000
     6.3 @@ -25,12 +25,10 @@ NETIF_DRIVER_STATUS_UP    = 1
     6.4  pendmsg = None
     6.5  pendaddr = None
     6.6  
     6.7 -recovery = False # Is a recovery in progress? (if so, we'll need to notify guests)
     6.8 +recovery = False # Is a recovery in progress?
     6.9  be_port  = None  # Port object for backend domain
    6.10  
    6.11  def backend_tx_req(msg):
    6.12 -    if not xend.netif.be_port:
    6.13 -        print "BUG: attempt to transmit request to non-existant netif driver"
    6.14      if xend.netif.be_port.space_to_write_request():
    6.15          xend.netif.be_port.write_request(msg)
    6.16          xend.netif.be_port.notify()
    6.17 @@ -42,7 +40,8 @@ def backend_rx_req(port, msg):
    6.18      subtype = (msg.get_header())['subtype']
    6.19      print "Received netif-be request, subtype %d" % subtype
    6.20      if subtype == CMSG_NETIF_BE_DRIVER_STATUS_CHANGED:
    6.21 -        (status, dummy) = struct.unpack("II", msg.get_payload())
    6.22 +        pl = msg.get_payload()
    6.23 +        status = pl['status']
    6.24          if status == NETIF_DRIVER_STATUS_UP:
    6.25              if xend.netif.recovery:
    6.26                  print "New netif backend now UP, notifying guests:"
    6.27 @@ -50,17 +49,13 @@ def backend_rx_req(port, msg):
    6.28                      netif = interface.list[netif_key]
    6.29                      netif.create()
    6.30                      print "  Notifying %d" % netif.dom
    6.31 -                    msg = xend.utils.message(CMSG_NETIF_FE,                   \
    6.32 -                                    CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0)
    6.33 -                    msg.append_payload(struct.pack("IIIBBBBBBBB", \
    6.34 -                                                   0,1,0,0,0,0,0,0,0,0,0))
    6.35 -                    netif.ctrlif_tx_req(xend.main.port_from_dom(netif.dom), msg)
    6.36 +                    msg = xend.utils.message(
    6.37 +                        CMSG_NETIF_FE,
    6.38 +                        CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0,
    6.39 +                        { 'handle' : 0, 'status' : 1 })
    6.40 +                    netif.ctrlif_tx_req(xend.main.port_from_dom(netif.dom),msg)
    6.41                  print "Done notifying guests"
    6.42                  recovery = False
    6.43 -            else: # No recovery in progress.
    6.44 -                if xend.netif.be_port: # This should never be true! (remove later)
    6.45 -                    print "BUG: unexpected netif backend UP message from %d" \
    6.46 -                          % port.remote_dom
    6.47          else:
    6.48              print "Unexpected net backend driver status: %d" % status
    6.49  
    6.50 @@ -71,17 +66,21 @@ def backend_rx_rsp(port, msg):
    6.51          rsp = { 'success': True }
    6.52          xend.main.send_management_response(rsp, xend.netif.pendaddr)
    6.53      elif subtype == CMSG_NETIF_BE_CONNECT:
    6.54 -        (dom,hnd,evtchn,tx_frame,rx_frame,st) = \
    6.55 -           struct.unpack("IIILLI", msg.get_payload())
    6.56 +        pl = msg.get_payload()
    6.57 +        (dom, hnd, evtchn, tx_frame, rx_frame, st) = (
    6.58 +            pl['domid'], pl['netif_handle'], pl['evtchn'],
    6.59 +            pl['tx_shmem_frame'], pl['rx_shmem_frame'], pl['status'])
    6.60          netif = interface.list[xend.main.port_from_dom(dom).local_port]
    6.61 -        msg = xend.utils.message(CMSG_NETIF_FE, \
    6.62 -                                 CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0)
    6.63 -        msg.append_payload(struct.pack("IIIBBBBBBBB",0,2,         \
    6.64 -                                       netif.evtchn['port2'],     \
    6.65 -                                       netif.mac[0],netif.mac[1], \
    6.66 -                                       netif.mac[2],netif.mac[3], \
    6.67 -                                       netif.mac[4],netif.mac[5], \
    6.68 -                                       0,0))
    6.69 +        msg = xend.utils.message(CMSG_NETIF_FE,
    6.70 +                                 CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0,
    6.71 +                                 { 'handle' : 0, 'status' : 2,
    6.72 +                                   'evtchn' : netif.evtchn['port2'],
    6.73 +                                   'mac[0]' : netif.mac[0],
    6.74 +                                   'mac[1]' : netif.mac[1],
    6.75 +                                   'mac[2]' : netif.mac[2],
    6.76 +                                   'mac[3]' : netif.mac[3],
    6.77 +                                   'mac[4]' : netif.mac[4],
    6.78 +                                   'mac[5]' : netif.mac[5] })
    6.79          netif.ctrlif_tx_req(xend.main.port_list[netif.key], msg)
    6.80  
    6.81  def backend_do_work(port):
    6.82 @@ -125,12 +124,14 @@ class interface:
    6.83      def create(self):
    6.84          """Notify the current network back end to create the virtual interface
    6.85          represented by this object."""
    6.86 -        msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_CREATE, 0)
    6.87 -        msg.append_payload(struct.pack("IIBBBBBBBBI",self.dom,0, \
    6.88 -                                       self.mac[0],self.mac[1],  \
    6.89 -                                       self.mac[2],self.mac[3],  \
    6.90 -                                       self.mac[4],self.mac[5],  \
    6.91 -                                       0,0,0))
    6.92 +        msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_CREATE, 0,
    6.93 +                                 { 'domid' : self.dom, 'netif_handle' : 0,
    6.94 +                                   'mac[0]' : self.mac[0],
    6.95 +                                   'mac[1]' : self.mac[1],
    6.96 +                                   'mac[2]' : self.mac[2],
    6.97 +                                   'mac[3]' : self.mac[3],
    6.98 +                                   'mac[4]' : self.mac[4],
    6.99 +                                   'mac[5]' : self.mac[5] })
   6.100          xend.netif.pendaddr = xend.main.mgmt_req_addr
   6.101          backend_tx_req(msg)
   6.102  
   6.103 @@ -138,8 +139,8 @@ class interface:
   6.104      # Completely destroy this interface.
   6.105      def destroy(self):
   6.106          del interface.list[self.key]
   6.107 -        msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY, 0)
   6.108 -        msg.append_payload(struct.pack("III",self.dom,0,0))
   6.109 +        msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY, 0,
   6.110 +                                 { 'domid' : self.dom, 'netif_handle' : 0 })
   6.111          backend_tx_req(msg)        
   6.112  
   6.113  
   6.114 @@ -164,23 +165,23 @@ class interface:
   6.115          subtype = (msg.get_header())['subtype']
   6.116          if subtype == CMSG_NETIF_FE_DRIVER_STATUS_CHANGED:
   6.117              print "netif driver up message from %d" % port.remote_dom
   6.118 -            msg = xend.utils.message(CMSG_NETIF_FE, \
   6.119 -                                     CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0)
   6.120 -            msg.append_payload(struct.pack("IIIBBBBBBBB",0,1,0,self.mac[0], \
   6.121 -                                           self.mac[1],self.mac[2], \
   6.122 -                                           self.mac[3],self.mac[4], \
   6.123 -                                           self.mac[5],0,0))
   6.124 +            msg = xend.utils.message(CMSG_NETIF_FE,
   6.125 +                                     CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0,
   6.126 +                                     { 'handle' : 0, 'status' : 1 })
   6.127              self.ctrlif_tx_req(port, msg)
   6.128          elif subtype == CMSG_NETIF_FE_INTERFACE_CONNECT:
   6.129              print "netif connect request from %d" % port.remote_dom
   6.130 -            (hnd,tx_frame,rx_frame) = struct.unpack("ILL", msg.get_payload())
   6.131 +            pl = msg.get_payload()
   6.132 +            (hnd, tx_frame, rx_frame) = (pl['handle'], pl['tx_shmem_frame'],
   6.133 +                                         pl['rx_shmem_frame'])
   6.134              xc = Xc.new()
   6.135 -            self.evtchn = xc.evtchn_bind_interdomain( \
   6.136 -                dom1=xend.netif.be_port.remote_dom,   \
   6.137 +            self.evtchn = xc.evtchn_bind_interdomain(
   6.138 +                dom1=xend.netif.be_port.remote_dom,
   6.139                  dom2=self.dom)
   6.140 -            msg = xend.utils.message(CMSG_NETIF_BE, \
   6.141 -                                     CMSG_NETIF_BE_CONNECT, 0)
   6.142 -            msg.append_payload(struct.pack("IIILLI",self.dom,0, \
   6.143 -                                           self.evtchn['port1'],tx_frame, \
   6.144 -                                           rx_frame,0))
   6.145 +            msg = xend.utils.message(CMSG_NETIF_BE,
   6.146 +                                     CMSG_NETIF_BE_CONNECT, 0,
   6.147 +                                     { 'domid' : self.dom, 'netif_handle' : 0,
   6.148 +                                       'tx_shmem_frame' : tx_frame,
   6.149 +                                       'rx_shmem_frame' : rx_frame,
   6.150 +                                       'evtchn' : self.evtchn['port1'] })
   6.151              backend_tx_req(msg)
     7.1 --- a/tools/xend/lib/utils.c	Fri Jun 04 14:07:21 2004 +0000
     7.2 +++ b/tools/xend/lib/utils.c	Fri Jun 04 15:20:17 2004 +0000
     7.3 @@ -235,6 +235,23 @@ static PyTypeObject xu_notifier_type = {
     7.4   * *********************** MESSAGE ***********************
     7.5   */
     7.6  
     7.7 +#define TYPE(_x,_y) (((_x)<<8)|(_y))
     7.8 +#define P2C(_struct, _field, _pytype, _ctype1, _ctype2)                   \
     7.9 +    do {                                                                  \
    7.10 +        PyObject *obj;                                                    \
    7.11 +        if ( ((obj = PyDict_GetItemString(payload, #_field)) != NULL) &&  \
    7.12 +             Py ## _pytype ## _Check(obj) )                               \
    7.13 +            ((_struct *)&xum->msg.msg[0])->_field =                       \
    7.14 +                (_ctype2)Py ## _pytype ## _As ## _ctype1(obj);            \
    7.15 +        xum->msg.length = sizeof(_struct);                                \
    7.16 +    } while ( 0 )
    7.17 +#define C2P(_struct, _field, _pytype, _ctype1, _ctype2)                   \
    7.18 +    do {                                                                  \
    7.19 +        PyObject *obj = Py ## _pytype ## _From ## _ctype1                 \
    7.20 +                        (((_struct *)&xum->msg.msg[0])->_field);          \
    7.21 +        PyDict_SetItemString(dict, #_field, obj);                         \
    7.22 +    } while ( 0 )
    7.23 +
    7.24  typedef struct {
    7.25      PyObject_HEAD;
    7.26      control_msg_t msg;
    7.27 @@ -262,13 +279,157 @@ static PyObject *xu_message_append_paylo
    7.28      return Py_None;
    7.29  }
    7.30  
    7.31 +static PyObject *xu_message_set_response_fields(PyObject *self, PyObject *args)
    7.32 +{
    7.33 +    xu_message_object *xum = (xu_message_object *)self;
    7.34 +    PyObject *payload;
    7.35 +
    7.36 +    if ( !PyArg_ParseTuple(args, "O", &payload) )
    7.37 +        return NULL;
    7.38 +
    7.39 +    switch ( TYPE(xum->msg.type, xum->msg.subtype) )
    7.40 +    {
    7.41 +    case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED):
    7.42 +        P2C(blkif_fe_driver_status_changed_t, nr_interfaces, Int, Long, u32);
    7.43 +        break;
    7.44 +    case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_DRIVER_STATUS_CHANGED):
    7.45 +        P2C(netif_fe_driver_status_changed_t, nr_interfaces, Int, Long, u32);
    7.46 +        break;
    7.47 +    }
    7.48 +
    7.49 +    Py_INCREF(Py_None);
    7.50 +    return Py_None;
    7.51 +}
    7.52 +
    7.53  static PyObject *xu_message_get_payload(PyObject *self, PyObject *args)
    7.54  {
    7.55      xu_message_object *xum = (xu_message_object *)self;
    7.56 +    PyObject *dict;
    7.57  
    7.58      if ( !PyArg_ParseTuple(args, "") )
    7.59          return NULL;
    7.60  
    7.61 +    dict = PyDict_New();
    7.62 +
    7.63 +    switch ( TYPE(xum->msg.type, xum->msg.subtype) )
    7.64 +    {
    7.65 +    case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED):
    7.66 +        C2P(blkif_fe_interface_status_changed_t, handle, Int, Long, u32);
    7.67 +        C2P(blkif_fe_interface_status_changed_t, status, Int, Long, u32);
    7.68 +        C2P(blkif_fe_interface_status_changed_t, evtchn, Int, Long, u16);
    7.69 +        return dict;
    7.70 +    case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED):
    7.71 +        C2P(blkif_fe_driver_status_changed_t, status, Int, Long, u32);
    7.72 +        return dict;
    7.73 +    case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_CONNECT):
    7.74 +        C2P(blkif_fe_interface_connect_t, handle,      Int, Long, u32);
    7.75 +        C2P(blkif_fe_interface_connect_t, shmem_frame, Int, Long, memory_t);
    7.76 +        return dict;
    7.77 +    case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_DISCONNECT):
    7.78 +        C2P(blkif_fe_interface_disconnect_t, handle, Int, Long, u32);
    7.79 +        return dict;
    7.80 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CREATE):
    7.81 +        C2P(blkif_be_create_t, domid,        Int, Long, u32);
    7.82 +        C2P(blkif_be_create_t, blkif_handle, Int, Long, u32);
    7.83 +        C2P(blkif_be_create_t, status, Int, Long, u32);
    7.84 +        return dict;
    7.85 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DESTROY):
    7.86 +        C2P(blkif_be_destroy_t, domid,        Int, Long, u32);
    7.87 +        C2P(blkif_be_destroy_t, blkif_handle, Int, Long, u32);
    7.88 +        C2P(blkif_be_destroy_t, status, Int, Long, u32);
    7.89 +        return dict;
    7.90 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CONNECT):
    7.91 +        C2P(blkif_be_connect_t, domid,        Int, Long, u32);
    7.92 +        C2P(blkif_be_connect_t, blkif_handle, Int, Long, u32);
    7.93 +        C2P(blkif_be_connect_t, shmem_frame,  Int, Long, memory_t);
    7.94 +        C2P(blkif_be_connect_t, evtchn,       Int, Long, u16);
    7.95 +        C2P(blkif_be_connect_t, status, Int, Long, u32);
    7.96 +        return dict;
    7.97 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DISCONNECT):
    7.98 +        C2P(blkif_be_disconnect_t, domid,        Int, Long, u32);
    7.99 +        C2P(blkif_be_disconnect_t, blkif_handle, Int, Long, u32);
   7.100 +        C2P(blkif_be_disconnect_t, status, Int, Long, u32);
   7.101 +        return dict;
   7.102 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE):
   7.103 +        C2P(blkif_be_vbd_create_t, domid,        Int, Long, u32);
   7.104 +        C2P(blkif_be_vbd_create_t, blkif_handle, Int, Long, u32);
   7.105 +        C2P(blkif_be_vbd_create_t, vdevice,      Int, Long, blkif_vdev_t);
   7.106 +        C2P(blkif_be_vbd_create_t, readonly,     Int, Long, u16);
   7.107 +        C2P(blkif_be_vbd_create_t, status, Int, Long, u32);
   7.108 +        return dict;
   7.109 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_DESTROY):
   7.110 +        C2P(blkif_be_vbd_destroy_t, domid,        Int, Long, u32);
   7.111 +        C2P(blkif_be_vbd_destroy_t, blkif_handle, Int, Long, u32);
   7.112 +        C2P(blkif_be_vbd_destroy_t, vdevice,      Int, Long, blkif_vdev_t);
   7.113 +        C2P(blkif_be_vbd_destroy_t, status, Int, Long, u32);
   7.114 +        return dict;
   7.115 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW):
   7.116 +        C2P(blkif_be_vbd_grow_t, domid,        Int, Long, u32);
   7.117 +        C2P(blkif_be_vbd_grow_t, blkif_handle, Int, Long, u32);
   7.118 +        C2P(blkif_be_vbd_grow_t, vdevice,      Int, Long, blkif_vdev_t);
   7.119 +        C2P(blkif_be_vbd_grow_t, extent.sector_start, 
   7.120 +             Long, UnsignedLongLong, blkif_sector_t);
   7.121 +        C2P(blkif_be_vbd_grow_t, extent.sector_length, 
   7.122 +             Long, UnsignedLongLong, blkif_sector_t);
   7.123 +        C2P(blkif_be_vbd_grow_t, extent.device, 
   7.124 +             Int, Long, blkif_pdev_t);
   7.125 +        C2P(blkif_be_vbd_grow_t, status, Int, Long, u32);
   7.126 +        return dict;
   7.127 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_SHRINK):
   7.128 +        C2P(blkif_be_vbd_shrink_t, domid,        Int, Long, u32);
   7.129 +        C2P(blkif_be_vbd_shrink_t, blkif_handle, Int, Long, u32);
   7.130 +        C2P(blkif_be_vbd_shrink_t, vdevice,      Int, Long, blkif_vdev_t);
   7.131 +        C2P(blkif_be_vbd_shrink_t, status, Int, Long, u32);
   7.132 +        return dict;
   7.133 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DRIVER_STATUS_CHANGED):
   7.134 +        C2P(blkif_be_driver_status_changed_t, status, Int, Long, u32);
   7.135 +        return dict;
   7.136 +    case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED):
   7.137 +        C2P(netif_fe_interface_status_changed_t, handle, Int, Long, u32);
   7.138 +        C2P(netif_fe_interface_status_changed_t, status, Int, Long, u32);
   7.139 +        C2P(netif_fe_interface_status_changed_t, evtchn, Int, Long, u16);
   7.140 +        return dict;
   7.141 +    case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_DRIVER_STATUS_CHANGED):
   7.142 +        C2P(netif_fe_driver_status_changed_t, status, Int, Long, u32);
   7.143 +        return dict;
   7.144 +    case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_INTERFACE_CONNECT):
   7.145 +        C2P(netif_fe_interface_connect_t, handle,         Int, Long, u32);
   7.146 +        C2P(netif_fe_interface_connect_t, tx_shmem_frame, Int, Long, memory_t);
   7.147 +        C2P(netif_fe_interface_connect_t, rx_shmem_frame, Int, Long, memory_t);
   7.148 +        return dict;
   7.149 +    case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_INTERFACE_DISCONNECT):
   7.150 +        C2P(netif_fe_interface_disconnect_t, handle, Int, Long, u32);
   7.151 +        return dict;
   7.152 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_CREATE):
   7.153 +        C2P(netif_be_create_t, domid,        Int, Long, u32);
   7.154 +        C2P(netif_be_create_t, netif_handle, Int, Long, u32);
   7.155 +        C2P(netif_be_create_t, status, Int, Long, u32);
   7.156 +        return dict;
   7.157 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY):
   7.158 +        C2P(netif_be_destroy_t, domid,        Int, Long, u32);
   7.159 +        C2P(netif_be_destroy_t, netif_handle, Int, Long, u32);
   7.160 +        C2P(netif_be_destroy_t, status, Int, Long, u32);
   7.161 +        return dict;
   7.162 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_CONNECT):
   7.163 +        C2P(netif_be_connect_t, domid,          Int, Long, u32);
   7.164 +        C2P(netif_be_connect_t, netif_handle,   Int, Long, u32);
   7.165 +        C2P(netif_be_connect_t, tx_shmem_frame, Int, Long, memory_t);
   7.166 +        C2P(netif_be_connect_t, rx_shmem_frame, Int, Long, memory_t);
   7.167 +        C2P(netif_be_connect_t, evtchn,         Int, Long, u16);
   7.168 +        C2P(netif_be_connect_t, status, Int, Long, u32);
   7.169 +        return dict;
   7.170 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DISCONNECT):
   7.171 +        C2P(netif_be_disconnect_t, domid,        Int, Long, u32);
   7.172 +        C2P(netif_be_disconnect_t, netif_handle, Int, Long, u32);
   7.173 +        C2P(netif_be_disconnect_t, status, Int, Long, u32);
   7.174 +        return dict;
   7.175 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DRIVER_STATUS_CHANGED):
   7.176 +        C2P(netif_be_driver_status_changed_t, status, Int, Long, u32);
   7.177 +        return dict;
   7.178 +    }
   7.179 +
   7.180 +    PyObject_Del(dict); /* didn't use it after all */
   7.181 +
   7.182      return PyString_FromStringAndSize(xum->msg.msg, xum->msg.length);
   7.183  }
   7.184  
   7.185 @@ -315,6 +476,11 @@ static PyMethodDef xu_message_methods[] 
   7.186        METH_VARARGS,
   7.187        "Append @str to the message payload.\n" },
   7.188  
   7.189 +    { "set_response_fields",
   7.190 +      (PyCFunction)xu_message_set_response_fields,
   7.191 +      METH_VARARGS,
   7.192 +      "Fill in the response fields in a message that was passed to us.\n" },
   7.193 +
   7.194      { "get_payload",
   7.195        (PyCFunction)xu_message_get_payload,
   7.196        METH_VARARGS,
   7.197 @@ -339,8 +505,9 @@ static PyObject *xu_message_new(PyObject
   7.198  {
   7.199      xu_message_object *xum;
   7.200      int type, subtype, id;
   7.201 +    PyObject *payload = NULL;
   7.202  
   7.203 -    if ( !PyArg_ParseTuple(args, "iii", &type, &subtype, &id) )
   7.204 +    if ( !PyArg_ParseTuple(args, "iii|O", &type, &subtype, &id, &payload) )
   7.205          return NULL;
   7.206  
   7.207      xum = PyObject_New(xu_message_object, &xu_message_type);
   7.208 @@ -350,7 +517,110 @@ static PyObject *xu_message_new(PyObject
   7.209      xum->msg.id      = id;
   7.210      xum->msg.length  = 0;
   7.211  
   7.212 +    if ( payload == NULL )
   7.213 +        return (PyObject *)xum;
   7.214 +
   7.215 +    if ( !PyDict_Check(payload) )
   7.216 +    {
   7.217 +        PyErr_SetString(PyExc_TypeError, "payload is not a dictionary");
   7.218 +        goto fail;
   7.219 +    }
   7.220 +
   7.221 +    switch ( TYPE(type, subtype) )
   7.222 +    {
   7.223 +    case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED):
   7.224 +        P2C(blkif_fe_interface_status_changed_t, handle, Int, Long, u32);
   7.225 +        P2C(blkif_fe_interface_status_changed_t, status, Int, Long, u32);
   7.226 +        P2C(blkif_fe_interface_status_changed_t, evtchn, Int, Long, u16);
   7.227 +        break;
   7.228 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CREATE):
   7.229 +        P2C(blkif_be_create_t, domid,        Int, Long, u32);
   7.230 +        P2C(blkif_be_create_t, blkif_handle, Int, Long, u32);
   7.231 +        break;
   7.232 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DESTROY):
   7.233 +        P2C(blkif_be_destroy_t, domid,        Int, Long, u32);
   7.234 +        P2C(blkif_be_destroy_t, blkif_handle, Int, Long, u32);
   7.235 +        break;
   7.236 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CONNECT):
   7.237 +        P2C(blkif_be_connect_t, domid,        Int, Long, u32);
   7.238 +        P2C(blkif_be_connect_t, blkif_handle, Int, Long, u32);
   7.239 +        P2C(blkif_be_connect_t, shmem_frame,  Int, Long, memory_t);
   7.240 +        P2C(blkif_be_connect_t, evtchn,       Int, Long, u16);
   7.241 +        break;
   7.242 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DISCONNECT):
   7.243 +        P2C(blkif_be_disconnect_t, domid,        Int, Long, u32);
   7.244 +        P2C(blkif_be_disconnect_t, blkif_handle, Int, Long, u32);
   7.245 +        break;
   7.246 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE):
   7.247 +        P2C(blkif_be_vbd_create_t, domid,        Int, Long, u32);
   7.248 +        P2C(blkif_be_vbd_create_t, blkif_handle, Int, Long, u32);
   7.249 +        P2C(blkif_be_vbd_create_t, vdevice,      Int, Long, blkif_vdev_t);
   7.250 +        P2C(blkif_be_vbd_create_t, readonly,     Int, Long, u16);
   7.251 +        break;
   7.252 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_DESTROY):
   7.253 +        P2C(blkif_be_vbd_destroy_t, domid,        Int, Long, u32);
   7.254 +        P2C(blkif_be_vbd_destroy_t, blkif_handle, Int, Long, u32);
   7.255 +        P2C(blkif_be_vbd_destroy_t, vdevice,      Int, Long, blkif_vdev_t);
   7.256 +        break;
   7.257 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW):
   7.258 +        P2C(blkif_be_vbd_grow_t, domid,        Int, Long, u32);
   7.259 +        P2C(blkif_be_vbd_grow_t, blkif_handle, Int, Long, u32);
   7.260 +        P2C(blkif_be_vbd_grow_t, vdevice,      Int, Long, blkif_vdev_t);
   7.261 +        P2C(blkif_be_vbd_grow_t, extent.sector_start, 
   7.262 +             Long, UnsignedLongLong, blkif_sector_t);
   7.263 +        P2C(blkif_be_vbd_grow_t, extent.sector_length, 
   7.264 +             Long, UnsignedLongLong, blkif_sector_t);
   7.265 +        P2C(blkif_be_vbd_grow_t, extent.device, 
   7.266 +             Int, Long, blkif_pdev_t);
   7.267 +        break;
   7.268 +    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_SHRINK):
   7.269 +        P2C(blkif_be_vbd_shrink_t, domid,        Int, Long, u32);
   7.270 +        P2C(blkif_be_vbd_shrink_t, blkif_handle, Int, Long, u32);
   7.271 +        P2C(blkif_be_vbd_shrink_t, vdevice,      Int, Long, blkif_vdev_t);
   7.272 +        break;
   7.273 +    case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED):
   7.274 +        P2C(netif_fe_interface_status_changed_t, handle, Int, Long, u32);
   7.275 +        P2C(netif_fe_interface_status_changed_t, status, Int, Long, u32);
   7.276 +        P2C(netif_fe_interface_status_changed_t, evtchn, Int, Long, u16);
   7.277 +        P2C(netif_fe_interface_status_changed_t, mac[0], Int, Long, u8);
   7.278 +        P2C(netif_fe_interface_status_changed_t, mac[1], Int, Long, u8);
   7.279 +        P2C(netif_fe_interface_status_changed_t, mac[2], Int, Long, u8);
   7.280 +        P2C(netif_fe_interface_status_changed_t, mac[3], Int, Long, u8);
   7.281 +        P2C(netif_fe_interface_status_changed_t, mac[4], Int, Long, u8);
   7.282 +        P2C(netif_fe_interface_status_changed_t, mac[5], Int, Long, u8);
   7.283 +        break;
   7.284 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_CREATE):
   7.285 +        P2C(netif_be_create_t, domid,        Int, Long, u32);
   7.286 +        P2C(netif_be_create_t, netif_handle, Int, Long, u32);
   7.287 +        P2C(netif_be_create_t, mac[0],       Int, Long, u8);
   7.288 +        P2C(netif_be_create_t, mac[1],       Int, Long, u8);
   7.289 +        P2C(netif_be_create_t, mac[2],       Int, Long, u8);
   7.290 +        P2C(netif_be_create_t, mac[3],       Int, Long, u8);
   7.291 +        P2C(netif_be_create_t, mac[4],       Int, Long, u8);
   7.292 +        P2C(netif_be_create_t, mac[5],       Int, Long, u8);
   7.293 +        break;
   7.294 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY):
   7.295 +        P2C(netif_be_destroy_t, domid,        Int, Long, u32);
   7.296 +        P2C(netif_be_destroy_t, netif_handle, Int, Long, u32);
   7.297 +        break;
   7.298 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_CONNECT):
   7.299 +        P2C(netif_be_connect_t, domid,          Int, Long, u32);
   7.300 +        P2C(netif_be_connect_t, netif_handle,   Int, Long, u32);
   7.301 +        P2C(netif_be_connect_t, tx_shmem_frame, Int, Long, memory_t);
   7.302 +        P2C(netif_be_connect_t, rx_shmem_frame, Int, Long, memory_t);
   7.303 +        P2C(netif_be_connect_t, evtchn,         Int, Long, u16);
   7.304 +        break;
   7.305 +    case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DISCONNECT):
   7.306 +        P2C(netif_be_disconnect_t, domid,        Int, Long, u32);
   7.307 +        P2C(netif_be_disconnect_t, netif_handle, Int, Long, u32);
   7.308 +        break;
   7.309 +    }
   7.310 +
   7.311      return (PyObject *)xum;
   7.312 +
   7.313 + fail:
   7.314 +    PyObject_Del((PyObject *)xum);
   7.315 +    return NULL;
   7.316  }
   7.317  
   7.318  static PyObject *xu_message_getattr(PyObject *obj, char *name)
     8.1 --- a/xen/include/hypervisor-ifs/hypervisor-if.h	Fri Jun 04 14:07:21 2004 +0000
     8.2 +++ b/xen/include/hypervisor-ifs/hypervisor-if.h	Fri Jun 04 15:20:17 2004 +0000
     8.3 @@ -381,26 +381,32 @@ typedef struct shared_info_st
     8.4  #define MAX_CMDLINE 256
     8.5  #define BASIC_START_INFO                                                      \
     8.6      /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.     */ \
     8.7 -    unsigned long nr_pages;       /* total pages allocated to this domain. */ \
     8.8 -    unsigned long shared_info;    /* MACHINE address of shared info struct.*/ \
     8.9 -    unsigned long flags;          /* SIF_xxx flags.                        */ \
    8.10 +    memory_t nr_pages;       /*  0: Total pages allocated to this domain. */  \
    8.11 +    _MEMORY_PADDING(A);                                                       \
    8.12 +    memory_t shared_info;    /*  8: MACHINE address of shared info struct.*/  \
    8.13 +    _MEMORY_PADDING(B);                                                       \
    8.14 +    u32      flags;          /* 16: SIF_xxx flags.                        */  \
    8.15 +    u32      __pad;                                                           \
    8.16      /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).      */ \
    8.17 -    unsigned long pt_base;        /* VIRTUAL address of page directory.    */ \
    8.18 -    unsigned long nr_pt_frames;   /* Number of bootstrap p.t. frames.      */ \
    8.19 -    unsigned long mfn_list;       /* VIRTUAL address of page-frame list.   */ \
    8.20 -    unsigned long mod_start;      /* VIRTUAL address of pre-loaded module. */ \
    8.21 -    unsigned long mod_len;        /* Size (bytes) of pre-loaded module.    */ \
    8.22 -    unsigned char cmd_line[MAX_CMDLINE]
    8.23 +    memory_t pt_base;        /* 24: VIRTUAL address of page directory.    */  \
    8.24 +    _MEMORY_PADDING(C);                                                       \
    8.25 +    memory_t nr_pt_frames;   /* 32: Number of bootstrap p.t. frames.      */  \
    8.26 +    _MEMORY_PADDING(D);                                                       \
    8.27 +    memory_t mfn_list;       /* 40: VIRTUAL address of page-frame list.   */  \
    8.28 +    _MEMORY_PADDING(E);                                                       \
    8.29 +    memory_t mod_start;      /* 48: VIRTUAL address of pre-loaded module. */  \
    8.30 +    _MEMORY_PADDING(F);                                                       \
    8.31 +    memory_t mod_len;        /* 56: Size (bytes) of pre-loaded module.    */  \
    8.32 +    _MEMORY_PADDING(G);                                                       \
    8.33 +    u8 cmd_line[MAX_CMDLINE] /* 64 */
    8.34  
    8.35  typedef struct {
    8.36      BASIC_START_INFO;
    8.37 -} start_info_t;
    8.38 +} PACKED start_info_t; /* 320 bytes */
    8.39  
    8.40  /* These flags are passed in the 'flags' field of start_info_t. */
    8.41 -#define SIF_PRIVILEGED 1          /* Is the domain privileged? */
    8.42 -#define SIF_INITDOMAIN 2          /* Is this the initial control domain? */
    8.43 -#define SIF_BLK_BE_DOMAIN 4       /* Is this a block backend domain? */
    8.44 -#define SIF_NET_BE_DOMAIN 8       /* Is this a net backend domain? */
    8.45 +#define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */
    8.46 +#define SIF_INITDOMAIN    (1<<1)  /* Is this the initial control domain? */
    8.47  
    8.48  /* For use in guest OSes. */
    8.49  extern shared_info_t *HYPERVISOR_shared_info;