1. 21 5月, 2013 1 次提交
  2. 15 5月, 2013 1 次提交
  3. 11 5月, 2013 2 次提交
    • L
      util: move virFile* functions from virutil.c to virfile.c · bfe7721d
      Laine Stump 提交于
      These all existed before virfile.c was created, and for some reason
      weren't moved.
      
      This is mostly straightfoward, although the syntax rule prohibiting
      write() had to be changed to have an exception for virfile.c instead
      of virutil.c.
      
      This movement pointed out that there is a function called
      virBuildPath(), and another almost identical function called
      virFileBuildPath(). They really should be a single function, which
      I'll take care of as soon as I figure out what the arglist should look
      like.
      bfe7721d
    • L
      util: fix virFileOpenAs return value and resulting error logs · a2c1bedb
      Laine Stump 提交于
      This resolves:
      
           https://bugzilla.redhat.com/show_bug.cgi?id=851411
           https://bugzilla.redhat.com/show_bug.cgi?id=955500
      
      The first problem was that virFileOpenAs was returning fd (-1) in one
      of the error cases rather than ret (-errno), so the caller thought
      that the error was EPERM rather than ENOENT.
      
      The second problem was that some log messages in the general purpose
      qemuOpenFile() function would always say "Failed to create" even if
      the caller hadn't included O_CREAT (i.e. they were trying to open an
      existing file).
      
      This fixes virFileOpenAs to jump down to the error return (which
      returns ret instead of fd) in the previously mentioned incorrect
      failure case of virFileOpenAs(), removes all error logging from
      virFileOpenAs() (since the callers report it), and modifies
      qemuOpenFile to appropriately use "open" or "create" in its log
      messages.
      
      NB: I seriously considered removing logging from all callers of
      virFileOpenAs(), but there is at least one case where the caller
      doesn't want virFileOpenAs() to log any errors, because it's just
      going to try again (qemuOpenFile()). We can't simply make a silent
      variation of virFileOpenAs() though, because qemuOpenFile() can't make
      the decision about whether or not it wants to retry until after
      virFileOpenAs() has already returned an error code.
      
      Likewise, I also considered changing virFileOpenAs() to return -1 with
      errno set on return, and may still do that, but only as a separate
      patch, as it obscures the intent of this patch too much.
      a2c1bedb
  4. 10 5月, 2013 1 次提交
  5. 09 5月, 2013 1 次提交
  6. 08 5月, 2013 1 次提交
    • O
      storage: Skip inactive lv volumes · 59750ed6
      Osier Yang 提交于
      If the volume is of a clustered volume group, and not active, the
      related pool APIs fails on opening /dev/vg/lv. If the volume is
      suspended, it hangs on open(2) the volume.
      
      Though the best solution is to expose the volume status in volume
      XML, and even better to provide API to activate/deactivate the volume,
      but it's not the work I want to touch currently. Volume status in
      other status is just fine to skip.
      
      About the 5th field of lv_attr (from man lvs[8])
      <quote>
       5 State: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid
         (S)uspended snapshot, snapshot (m)erge failed,suspended
         snapshot (M)erge failed, mapped (d)evice present without
         tables,  mapped device present with (i)nactive table
      </quote>
      59750ed6
  7. 03 5月, 2013 2 次提交
    • E
      build: avoid useless virAsprintf · 25ae3d30
      Eric Blake 提交于
      virAsprintf(&foo, "%s", bar) is wasteful compared to
      foo = strdup(bar) (or eventually, VIR_STRDUP(foo, bar),
      but one thing at a time...).
      
      Noticed while reviewing Laine's attempt to clean up broken
      qemu:///session.
      
      * cfg.mk (sc_prohibit_asprintf): Enhance rule.
      * src/esx/esx_storage_backend_vmfs.c
      (esxStorageBackendVMFSVolumeLookupByKey): Fix offender.
      * src/network/bridge_driver.c (networkStateInitialize): Likewise.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopDHCPOpen):
      Likewise.
      * src/storage/storage_backend_sheepdog.c
      (virStorageBackendSheepdogRefreshVol): Likewise.
      * src/util/vircgroup.c (virCgroupAddTaskStrController): Likewise.
      * src/util/virdnsmasq.c (addnhostsAdd): Likewise.
      * src/xen/block_stats.c (xenLinuxDomainDeviceID): Likewise.
      * src/xen/xen_driver.c (xenUnifiedConnectOpen): Likewise.
      * tools/virsh.c (vshGetTypedParamValue): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      25ae3d30
    • L
      util: fix compile errors caused by moving string functions · cc8f9e67
      Laine Stump 提交于
      commit 7c9a2d88 missed adding in a few #include "virstring.h"s, causing
      builds to fail.
      cc8f9e67
  8. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  9. 26 4月, 2013 1 次提交
    • E
      build: avoid unsafe functions in libgen.h · 1fbf1905
      Eric Blake 提交于
      POSIX says that both basename() and dirname() may return static
      storage (aka they need not be thread-safe); and that they may but
      not must modify their input argument.  Furthermore, <libgen.h>
      is not available on all platforms.  For these reasons, you should
      never use these functions in a multi-threaded library.
      
      Gnulib instead recommends a way to avoid the portability nightmare:
      gnulib's "dirname.h" provides useful thread-safe counterparts.  The
      obvious dir_name() and base_name() are GPL (because they malloc(),
      but call exit() on failure) so we can't use them; but the LGPL
      variants mdir_name() (malloc's or returns NULL) and last_component
      (always points into the incoming string without modifying it,
      differing from basename semantics only on corner cases like the
      empty string that we shouldn't be hitting in the first place) are
      already in use in libvirt.  This finishes the swap over to the safe
      functions.
      
      * cfg.mk (sc_prohibit_libgen): New rule.
      * src/util/vircgroup.c: Fix offenders.
      * src/parallels/parallels_storage.c (parallelsPoolAddByDomain):
      Likewise.
      * src/parallels/parallels_network.c (parallelsGetBridgedNetInfo):
      Likewise.
      * src/node_device/node_device_udev.c (udevProcessSCSIHost)
      (udevProcessSCSIDevice): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskDeleteVol): Likewise.
      * src/util/virpci.c (virPCIGetDeviceAddressFromSysfsLink):
      Likewise.
      * src/util/virstoragefile.h (_virStorageFileMetadata): Avoid false
      positive.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1fbf1905
  10. 24 4月, 2013 3 次提交
  11. 22 4月, 2013 1 次提交
  12. 13 4月, 2013 1 次提交
  13. 11 4月, 2013 2 次提交
  14. 08 4月, 2013 7 次提交
    • O
      storage: Guess the parent if it's not specified for vHBA · f5a61087
      Osier Yang 提交于
      This finds the parent for vHBA by iterating over all the HBA
      which supports vport_ops capability on the host, and return
      the first one which is online, not saturated (vports in use
      is less than max_vports).
      f5a61087
    • O
      storage: Add startPool and stopPool for scsi backend · 34f96510
      Osier Yang 提交于
      startPool creates the vHBA if it's not existed yet, stopPool destroys
      the vHBA. Also to support autostart, checkPool will creates the vHBA
      if it's not existed yet.
      34f96510
    • O
      util: Add helper to get the scsi host name by iterating over sysfs · b52fbad1
      Osier Yang 提交于
      The helper iterates over sysfs, to find out the matched scsi host
      name by comparing the wwnn,wwpn pair. It will be used by checkPool
      and refreshPool of storage scsi backend. New helper getAdapterName
      is introduced in storage_backend_scsi.c, which uses the new util
      helper virGetFCHostNameByWWN to get the fc_host adapter name.
      b52fbad1
    • O
      storage: Move virStorageBackendSCSIGetHostNumber into iscsi backend · 6cf9a5bb
      Osier Yang 提交于
      It's only used by iscsi backend.
      6cf9a5bb
    • O
      storage: Make the adapter name be consistent with node device driver · c1f63a9b
      Osier Yang 提交于
      node device driver names the HBA like "scsi_host5", but storage
      driver uses "host5", which could make the user confused. This
      changes them to be consistent. However, for back-compat reason,
      adapter name like "host5" is still supported.
      c1f63a9b
    • O
      New XML attributes for storage pool source adapter · 9f781da6
      Osier Yang 提交于
      This introduces 4 new attributes for storage pool source adapter.
      E.g.
      
      <adapter type='fc_host' parent='scsi_host5' wwnn='20000000c9831b4b' wwpn='10000000c9831b4b'/>
      
      Attribute 'type' can be either 'scsi_host' or 'fc_host', and defaults
      to 'scsi_host' if attribute 'name' is specified. I.e. It's optional
      for 'scsi_host' adapter, for back-compat reason. However, mandatory
      for 'fc_host' adapter and any new future adapter types. Attribute
      'parent' is to specify the parent for the fc_host adapter.
      
      * docs/formatstorage.html.in:
        - Add documents for the 4 new attrs
      * docs/schemas/storagepool.rng:
        - Add RNG schema
      * src/conf/storage_conf.c:
        - Parse and format the new XMLs
      * src/conf/storage_conf.h:
        - New struct virStoragePoolSourceAdapter, replace "char *adapter" with it;
        - New enum virStoragePoolSourceAdapterType
      * src/libvirt_private.syms:
        - Export TypeToString and TypeFromString
      * src/phyp/phyp_driver.c:
        - Replace "adapter" with "adapter.data.name", which is member of the union
          of the new struct virStoragePoolSourceAdapter now. Later patch will
          add the checking, as "adapter.data.name" is only valid for "scsi_host"
          adapter.
      * src/storage/storage_backend_scsi.c:
        - Like above
      * tests/storagepoolxml2xmlin/pool-scsi-type-scsi-host.xml:
      * tests/storagepoolxml2xmlin/pool-scsi-type-fc-host.xml:
        - New test for 'fc_host' and "scsi_host" adapter
      * tests/storagepoolxml2xmlout/pool-scsi.xml:
        - Change the expected output, as the 'type' defaults to 'scsi_host' if 'name"
          specified now
      * tests/storagepoolxml2xmlout/pool-scsi-type-scsi-host.xml:
      * tests/storagepoolxml2xmlout/pool-scsi-type-fc-host.xml:
        - New test
      * tests/storagepoolxml2xmltest.c:
        - Include the test
      9f781da6
    • D
      Disable cast-align warnings in various places · e57aaa6f
      Daniel P. Berrange 提交于
      There are a number of places which generate cast alignment
      warnings, which are difficult or impossible to address. Use
      pragmas to disable the warnings in these few places
      
      conf/nwfilter_conf.c: In function 'virNWFilterRuleDetailsParse':
      conf/nwfilter_conf.c:1806:16: warning: cast increases required alignment of target type [-Wcast-align]
               item = (nwItemDesc *)((char *)nwf + att[idx].dataIdx);
      conf/nwfilter_conf.c: In function 'virNWFilterRuleDefDetailsFormat':
      conf/nwfilter_conf.c:3238:16: warning: cast increases required alignment of target type [-Wcast-align]
               item = (nwItemDesc *)((char *)def + att[i].dataIdx);
      
      storage/storage_backend_mpath.c: In function 'virStorageBackendCreateVols':
      storage/storage_backend_mpath.c:247:17: warning: cast increases required alignment of target type [-Wcast-align]
               names = (struct dm_names *)(((char *)names) + next);
      
      nwfilter/nwfilter_dhcpsnoop.c: In function 'virNWFilterSnoopDHCPDecode':
      nwfilter/nwfilter_dhcpsnoop.c:994:15: warning: cast increases required alignment of target type [-Wcast-align]
               pip = (struct iphdr *) pep->eh_data;
      nwfilter/nwfilter_dhcpsnoop.c:1004:11: warning: cast increases required alignment of target type [-Wcast-align]
           pup = (struct udphdr *) ((char *) pip + (pip->ihl << 2));
      
      nwfilter/nwfilter_learnipaddr.c: In function 'procDHCPOpts':
      nwfilter/nwfilter_learnipaddr.c:327:33: warning: cast increases required alignment of target type [-Wcast-align]
                       uint32_t *tmp = (uint32_t *)&dhcpopt->value;
      nwfilter/nwfilter_learnipaddr.c: In function 'learnIPAddressThread':
      nwfilter/nwfilter_learnipaddr.c:501:43: warning: cast increases required alignment of target type [-Wcast-align]
                           struct iphdr *iphdr = (struct iphdr*)(packet +
      nwfilter/nwfilter_learnipaddr.c:538:43: warning: cast increases required alignment of target type [-Wcast-align]
                           struct iphdr *iphdr = (struct iphdr*)(packet +
      nwfilter/nwfilter_learnipaddr.c:544:48: warning: cast increases required alignment of target type [-Wcast-align]
                               struct udphdr *udphdr= (struct udphdr *)
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e57aaa6f
  15. 04 4月, 2013 1 次提交
    • A
      storage: Fix volume cloning for logical volume. · d369e508
      Atsushi Kumagai 提交于
      When creating a logical volume with virStorageVolCreateXMLFrom,
      "qemu-img convert" is called internally if clonevol is a file volume.
      Then, vol->target.format is used as output_fmt parameter but the
      target.format of logical volumes is always 0 because logical volumes
      haven't the volume format type element.
      
      Fortunately, 0 was treated as RAW file format before commit f772b3d9,
      so there was no problem. But now, 0 is treated as the type of none,
      qemu-img fails with "Unknown file format 'none'".
      
      This patch fixes this issue by treating output block devices as RAW
      file format like for input block devices.
      Signed-off-by: NAtsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
      d369e508
  16. 29 3月, 2013 1 次提交
  17. 20 3月, 2013 1 次提交
    • L
      storage: fix unlikely memory leak in rbd backend · 57f39e03
      Laine Stump 提交于
      virStorageBackendRBDRefreshPool() first allocates an array big enough
      to hold 1024 names, then calls rbd_list(), which returns ERANGE if the
      array isn't big enough. When that happens, the VIR_ALLOC_N is called
      again with a larger size. Unfortunately, the original array isn't
      freed before allocating a new one.
      57f39e03
  18. 06 3月, 2013 2 次提交
  19. 25 2月, 2013 6 次提交
  20. 23 2月, 2013 1 次提交
    • S
      storage: use f_frsize, not f_bsize, for calculating available space · c2092abf
      Sage Weil 提交于
      The bfree and blocks fields are supposed to be in units of frsize.  We were
      calculating capacity correctly using those units, but the available
      calculation was using bsize instead.  Most file systems report these as the
      same value specifically because many programs are buggy, but that is no
      reason to rely on that behavior, or to behave inconsistently.
      
      This bug has been present since e266ded2 (2008) and aa296e6c, when the code
      was originally introduced (the latter via cut and paste).
      Signed-off-by: NSage Weil <sage@newdream.net>
      c2092abf
  21. 16 2月, 2013 1 次提交
    • E
      regex: gnulib guarantees that we have regex support · ec8a2d03
      Eric Blake 提交于
      No need to use HAVE_REGEX_H - our use of gnulib guarantees that
      the header exists and works, regardless of platform.  Similarly,
      we can unconditionally assume a compiling <sys/wait.h> (although
      the mingw version of this header is not full-featured).
      
      * src/storage/storage_backend.c: Drop useless conditional.
      * tests/testutils.c: Likewise.
      ec8a2d03
  22. 14 2月, 2013 1 次提交
  23. 09 2月, 2013 1 次提交