Accept udev events about SCSI and update physical SCSI information
PATCH 1/1 Accept udev events about SCSI and update physical SCSI information
Hi,
This patch accepts udev events about SCSI devices and updates physical SCSI devices information.
Signed-off-by Masaki Kanno <[email protected]>
Best regards,
Kan
tools/hotplug/Linux/xend.rules +1 -1
@@ -1,3 +1,3 @@ SUBSYSTEM=="pci", RUN+="socket:/org/xen/ SUBSYSTEM=="pci", RUN+="socket:/org/xen/xend/udev_event" -#SUBSYSTEM=="scsi", RUN+="socket:/org/xen/xend/udev_event" +SUBSYSTEM=="scsi", RUN+="socket:/org/xen/xend/udev_event" #SUBSYSTEM=="net", KERNEL!="vif[0-9]*.[0-9]*|tap[0-9]*.[0-9]*", RUN+="socket:/org/xen/xend/udev_event"
tools/python/xen/util/vscsi_util.py +45 -35
85 lines not on this page · raw message
tools/python/xen/xend/XendNode.py +32 -8
@@ -374,14 +374,38 @@ class XendNode: XendAPIStore.get(ppci_ref, "PPCI").destroy() - def add_PSCSI(self): - # TODO - log.debug("add_network(): Not implemented.") - - - def remove_PSCSI(self): - # TODO - log.debug("add_network(): Not implemented.") + def add_PSCSI(self, add_HCTL): + saved_pscsis = self.state_store.load_state('pscsi') + saved_pscsi_table = {} + if saved_pscsis: + for saved_uuid, saved_record in saved_pscsis.items(): + try: + saved_pscsi_table[saved_record['scsi_id']] = saved_uuid + except KeyError: + pass + + # Initialise the PSCSI + pscsi_record = vscsi_util.get_scsi_device(add_HCTL) + if pscsi_record and pscsi_record['scsi_id']: + pscsi_uuid = saved_pscsi_table.get(pscsi_record['scsi_id'], None) + if pscsi_uuid is None: + pscsi_uuid = uuid.createString() + XendPSCSI(pscsi_uuid, pscsi_record) + self.save_PSCSIs() + + + def remove_PSCSI(self, rem_HCTL): + saved_pscsis = self.state_store.load_state('pscsi') + if not saved_pscsis: + return + + # Remove the PSCSI + for pscsi_record in saved_pscsis.values(): + if rem_HCTL == pscsi_record['physical_HCTL']: + pscsi_ref = XendPSCSI.get_by_HCTL(rem_HCTL) + XendAPIStore.get(pscsi_ref, "PSCSI").destroy() + self.save_PSCSIs() + return ## def network_destroy(self, net_uuid):
tools/python/xen/xend/server/udevevent.py +17 -5
@@ -40,13 +40,25 @@ class UdevEventProtocol(protocol.Protoco log.info("Removing pci device %s", pci_name) XendNode.instance().remove_PPCI(pci_name) - elif (udev_event.get('SUBSYSTEMS', None) == 'scsi'): + elif (udev_event.get('SUBSYSTEM', None) == 'scsi'): + hctl = None + devpath = udev_event.get('DEVPATH', None) + if devpath: + hctl = devpath.split('/')[-1] + if len(hctl.split(':')) != 4: + hctl = None + if hctl is None: + # By any possibility, if an HCTL isn't gotten from + # the udev event, the udev event is ignored. + log.warn("Invalid udev event about scsi received") + return + if (udev_event['ACTION'] == 'add'): - log.info("Adding scsi device") - XendNode.instance().add_PSCSI() + log.info("Adding scsi device %s", hctl) + XendNode.instance().add_PSCSI(hctl) elif (udev_event['ACTION'] == 'remove'): - log.info("Removing scci device") - XendNode.instance().remove_PSCSI() + log.info("Removing scsi device %s", hctl) + XendNode.instance().remove_PSCSI(hctl) elif (udev_event.get('SUBSYSTEM', None) == 'net'): interface = udev_event.get('INTERFACE', None)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel