]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Add "shareable" field for virSCSIDevice struct
authorOsier Yang <jyang@redhat.com>
Wed, 8 Jan 2014 14:51:29 +0000 (22:51 +0800)
committerOsier Yang <jyang@redhat.com>
Thu, 23 Jan 2014 09:52:33 +0000 (17:52 +0800)
Unlike the host devices of other types, SCSI host device XML supports
"shareable" tag. This patch introduces it for the virSCSIDevice struct
for a later patch use (to detect if the SCSI device is shareable when
preparing the SCSI host device in QEMU driver).

src/libvirt_private.syms
src/qemu/qemu_cgroup.c
src/qemu/qemu_hostdev.c
src/security/security_apparmor.c
src/security/security_dac.c
src/security/security_selinux.c
src/util/virscsi.c
src/util/virscsi.h

index d1a58f99be597596ced4b784094291ad8e3ab41a..13caf93eb0269dabbe3904f1360f4efd6e1ccd68 100644 (file)
@@ -1683,6 +1683,7 @@ virSCSIDeviceGetDevName;
 virSCSIDeviceGetName;
 virSCSIDeviceGetReadonly;
 virSCSIDeviceGetSgName;
+virSCSIDeviceGetShareable;
 virSCSIDeviceGetTarget;
 virSCSIDeviceGetUnit;
 virSCSIDeviceGetUsedBy;
index 1cc929c5ecae2392318d45953d679da59d2caf85..bb99f7436e6a5e9bc9a93f274e6d3871424c9b7d 100644 (file)
@@ -295,7 +295,8 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm,
                                          dev->source.subsys.u.scsi.bus,
                                          dev->source.subsys.u.scsi.target,
                                          dev->source.subsys.u.scsi.unit,
-                                         dev->readonly)) == NULL)
+                                         dev->readonly,
+                                         dev->shareable)) == NULL)
                 goto cleanup;
 
             if (virSCSIDeviceFileIterate(scsi,
index dee61e742d318677b218c715a1bff4049c68f991..86a463a65c69f592e257176ca522b596c1e4b382 100644 (file)
@@ -267,7 +267,8 @@ qemuUpdateActiveScsiHostdevs(virQEMUDriverPtr driver,
                                       hostdev->source.subsys.u.scsi.bus,
                                       hostdev->source.subsys.u.scsi.target,
                                       hostdev->source.subsys.u.scsi.unit,
-                                      hostdev->readonly)))
+                                      hostdev->readonly,
+                                      hostdev->shareable)))
             goto cleanup;
 
         virSCSIDeviceSetUsedBy(scsi, def->name);
@@ -1097,7 +1098,8 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
                                       hostdev->source.subsys.u.scsi.bus,
                                       hostdev->source.subsys.u.scsi.target,
                                       hostdev->source.subsys.u.scsi.unit,
-                                      hostdev->readonly)))
+                                      hostdev->readonly,
+                                      hostdev->shareable)))
             goto cleanup;
 
         if (scsi && virSCSIDeviceListAdd(list, scsi) < 0) {
@@ -1395,7 +1397,8 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
                                       hostdev->source.subsys.u.scsi.bus,
                                       hostdev->source.subsys.u.scsi.target,
                                       hostdev->source.subsys.u.scsi.unit,
-                                      hostdev->readonly))) {
+                                      hostdev->readonly,
+                                      hostdev->shareable))) {
             VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s",
                      hostdev->source.subsys.u.scsi.adapter,
                      hostdev->source.subsys.u.scsi.bus,
index a9f04d2519e393cf32882e27c234385c1ccb9b11..86a033f7418f429937d085c9abc6b5ec275d1496 100644 (file)
@@ -833,7 +833,8 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
                              dev->source.subsys.u.scsi.bus,
                              dev->source.subsys.u.scsi.target,
                              dev->source.subsys.u.scsi.unit,
-                             dev->readonly);
+                             dev->readonly,
+                             dev->shareable);
 
          if (!scsi)
              goto done;
index cb7d322f2c14191738dd3f02507409f521d01e39..0952df97ffa6ceda430bd6439d56dad96f25228a 100644 (file)
@@ -536,7 +536,8 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
                              dev->source.subsys.u.scsi.bus,
                              dev->source.subsys.u.scsi.target,
                              dev->source.subsys.u.scsi.unit,
-                             dev->readonly);
+                             dev->readonly,
+                             dev->shareable);
 
         if (!scsi)
             goto done;
@@ -653,7 +654,8 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
                              dev->source.subsys.u.scsi.bus,
                              dev->source.subsys.u.scsi.target,
                              dev->source.subsys.u.scsi.unit,
-                             dev->readonly);
+                             dev->readonly,
+                             dev->shareable);
 
         if (!scsi)
             goto done;
index c70ac773f3b688c009c9366a4d692f9f5aa379f1..7b6d8e330b2d4044740d924f4ef8f11edd086d38 100644 (file)
@@ -1354,7 +1354,8 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def,
                              dev->source.subsys.u.scsi.bus,
                              dev->source.subsys.u.scsi.target,
                              dev->source.subsys.u.scsi.unit,
-                             dev->readonly);
+                             dev->readonly,
+                             dev->shareable);
 
         if (!scsi)
             goto done;
@@ -1545,7 +1546,8 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
                              dev->source.subsys.u.scsi.bus,
                              dev->source.subsys.u.scsi.target,
                              dev->source.subsys.u.scsi.unit,
-                             dev->readonly);
+                             dev->readonly,
+                             dev->shareable);
 
             if (!scsi)
                 goto done;
index 751eaf05bf73bf69f7d20aacc331ce7138b70b66..3998c3a7ec8dc2791c69005c570da45d07fb5169 100644 (file)
@@ -58,6 +58,7 @@ struct _virSCSIDevice {
     const char *used_by; /* name of the domain using this dev */
 
     bool readonly;
+    bool shareable;
 };
 
 struct _virSCSIDeviceList {
@@ -185,7 +186,8 @@ virSCSIDeviceNew(const char *adapter,
                  unsigned int bus,
                  unsigned int target,
                  unsigned int unit,
-                 bool readonly)
+                 bool readonly,
+                 bool shareable)
 {
     virSCSIDevicePtr dev, ret = NULL;
     char *sg = NULL;
@@ -201,6 +203,7 @@ virSCSIDeviceNew(const char *adapter,
     dev->target = target;
     dev->unit = unit;
     dev->readonly = readonly;
+    dev->shareable= shareable;
 
     if (!(sg = virSCSIDeviceGetSgName(adapter, bus, target, unit)))
         goto cleanup;
@@ -311,6 +314,12 @@ virSCSIDeviceGetReadonly(virSCSIDevicePtr dev)
     return dev->readonly;
 }
 
+bool
+virSCSIDeviceGetShareable(virSCSIDevicePtr dev)
+{
+    return dev->shareable;
+}
+
 int
 virSCSIDeviceFileIterate(virSCSIDevicePtr dev,
                          virSCSIDeviceFileActor actor,
index 4c461f830d565973116571539dae60c6ab2ba753..b2e98cac6857deaaee9a6868d2ddcc7be87cd469 100644 (file)
@@ -46,7 +46,8 @@ virSCSIDevicePtr virSCSIDeviceNew(const char *adapter,
                                   unsigned int bus,
                                   unsigned int target,
                                   unsigned int unit,
-                                  bool readonly);
+                                  bool readonly,
+                                  bool shareable);
 
 void virSCSIDeviceFree(virSCSIDevicePtr dev);
 void virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev, const char *name);
@@ -57,6 +58,7 @@ unsigned int virSCSIDeviceGetBus(virSCSIDevicePtr dev);
 unsigned int virSCSIDeviceGetTarget(virSCSIDevicePtr dev);
 unsigned int virSCSIDeviceGetUnit(virSCSIDevicePtr dev);
 bool virSCSIDeviceGetReadonly(virSCSIDevicePtr dev);
+bool virSCSIDeviceGetShareable(virSCSIDevicePtr dev);
 
 /*
  * Callback that will be invoked once for each file