1. 19 8月, 2015 3 次提交
  2. 18 8月, 2015 3 次提交
    • E
      build: fix mingw build · 0a617b53
      Eric Blake 提交于
      Ever since commit e44b0269, 64-bit mingw compilation fails with:
      
      ../../src/util/virprocess.c: In function 'virProcessGetPids':
      ../../src/util/virprocess.c:628:50: error: passing argument 4 of 'virStrToLong_i' from incompatible pointer type [-Werror=incompatible-pointer-types]
               if (virStrToLong_i(ent->d_name, NULL, 10, &tmp_pid) < 0)
                                                        ^
      In file included from ../../src/util/virprocess.c:59:0:
      ../../src/util/virstring.h:53:5: note: expected 'int *' but argument is of type 'pid_t * {aka long long int *}'
       int virStrToLong_i(char const *s,
           ^
      cc1: all warnings being treated as errors
      
      Although mingw won't be using this function, it does compile the
      file, and the fix is relatively simple.
      
      * src/util/virprocess.c (virProcessGetPids): Don't assume pid_t
      fits in int.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0a617b53
    • M
      virHashAddEntry: Report error on duplicate key · 1dc25872
      Michal Privoznik 提交于
      If this function fails, the error message is reported only in
      some cases (e.g. OOM), but in some it's not (e.g. duplicate key).
      This fact is painful and we should either not report error at all
      or report the error in all possible cases. I vote for the latter.
      Unfortunately, since the key may be an arbitrary value (not
      necessarily a string) we can't report it in the error message.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      1dc25872
    • M
      virHashAddOrUpdateEntry: Turn @new_name into void * · 890676d2
      Michal Privoznik 提交于
      In 9190f0b0 we've tried to fix an OOM. And boy, was that fix
      successful. But back then, the hash table implementation worked
      strictly over string keys, which is not the case anymore. Hash
      table have this function keyCopy() which returns void *.
      Therefore a local variable that is temporarily holding the
      intermediate return value from that function should be void *
      too.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      890676d2
  3. 14 8月, 2015 1 次提交
    • E
      tools: Introduce new client generic module vsh · 834c5720
      Erik Skultety 提交于
      In order to share as much virsh' logic as possible with upcomming
      virt-admin client we need to split virsh logic into virsh specific and
      client generic features.
      
      Since majority of virsh methods should be generic enough to be used by
      other clients, it's much easier to rename virsh specific data to virshX
      than doing this vice versa. It moved generic virsh commands (including info
      and opts structures) to generic module vsh.c.
      
      Besides renaming methods and structures, this patch also involves introduction
      of a client specific control structure being referenced as private data in the
      original control structure, introduction of a new global vsh Initializer,
      which currently doesn't do much, but there is a potential for added
      functionality in the future.
      Lastly it introduced client hooks which are especially necessary during
      client connecting phase.
      834c5720
  4. 12 8月, 2015 1 次提交
    • L
      util: don't overwrite stack when getting ethtool gfeatures · bfaaa2b6
      Laine Stump 提交于
      This fixes the crash described here:
      
       https://www.redhat.com/archives/libvir-list/2015-August/msg00162.html
      
      In short, we were calling ioctl(SIOCETHTOOL) pointing to a too-short
      object that was a local on the stack, resulting in the memory past the
      end of the object being overwritten. This was because the struct used
      by the ETHTOOL_GFEATURES command of SIOCETHTOOL ends with a 0-length
      array, but we were telling ethtool that it could use 2 elements on the
      array.
      
      The fix is to allocate the necessary memory with VIR_ALLOC_VAR(),
      including the extra length needed for a 2 element array at the end.
      bfaaa2b6
  5. 11 8月, 2015 3 次提交
    • M
      virNetDevBandwidthUpdateRate: turn class_id into integer · 45090449
      Michal Privoznik 提交于
      This is no functional change. It's just that later in the series we
      will need to pass class_id as an integer.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      45090449
    • M
      virNetDevParseMcast: Avoid magic constant · 327bc16a
      Michal Privoznik 提交于
      There is no guarantee that an enum start it mapped onto a value
      of zero. However, we are guaranteed that enum items are
      consecutive integers. Moreover, it's a pity to define an enum to
      avoid using magical constants but then using them anyway.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      327bc16a
    • L
      network: validate network NAT range · a6f9af82
      Laine Stump 提交于
      This patch modifies virSocketAddrGetRange() to function properly when
      the containing network/prefix of the address range isn't known, for
      example in the case of the NAT range of a virtual network (since it is
      a range of addresses on the *host*, not within the network itself). We
      then take advantage of this new functionality to validate the NAT
      range of a virtual network.
      
      Extra test cases are also added to verify that virSocketAddrGetRange()
      works properly in both positive and negative cases when the network
      pointer is NULL.
      
      This is the *real* fix for:
      
      https://bugzilla.redhat.com/show_bug.cgi?id=985653
      
      Commits 1e334a and 48e8b9 had earlier been pushed as fixes for that
      bug, but I had neglected to read the report carefully, so instead of
      fixing validation for the NAT range, I had fixed validation for the
      DHCP range. sigh.
      a6f9af82
  6. 07 8月, 2015 1 次提交
  7. 06 8月, 2015 1 次提交
  8. 30 7月, 2015 2 次提交
  9. 24 7月, 2015 1 次提交
    • J
      nodeinfo: Check for SYSFS_INFINIBAND_DIR before open · 136f17ef
      John Ferlan 提交于
      Commit id 'ac3ed208' causes 'virsh nodedev-list --cap net' to fail
      on any system without SYSFS_INFINIBAND_DIR (/sys/class/infiniband).
      
      Rather than assume it's there and fail on the attempt to open the
      non-existent directory, check if it's there - if not, return
      success and move on. Also fix caller to check < 0 upon return.
      
      As reported by Suren Hajyan <shajyan@redhat.com> from run of unit tests
      136f17ef
  10. 22 7月, 2015 2 次提交
    • R
      netdev: fix build on FreeBSD · 830344d6
      Roman Bogorodskiy 提交于
      Commit ac3ed208 breaks build on FreeBSD with:
      
        CC       util/libvirt_util_la-virnetdev.lo
      util/virnetdev.c:2967:1: error: unused function 'virNetDevRDMAFeature' [-Werror,-Wunused-function]
      virNetDevRDMAFeature(const char *ifname,
      ^
      
      So hide virNetDevRDMAFeature function under the #ifdef 'SIOCETHTOOL'
      and 'HAVE_STRUCT_IFREQ' section.
      
      Pushed under the build breaker rule.
      830344d6
    • P
      cgroup: Drop resource partition from virSystemdMakeScopeName · 88f6c007
      Peter Krempa 提交于
      The scope name, even according to our docs is
      "machine-$DRIVER\x2d$VMNAME.scope" virSystemdMakeScopeName would use the
      resource partition name instead of "machine-" if it was specified thus
      creating invalid scope paths.
      
      This makes libvirt drop cgroups for a VM that uses custom resource
      partition upon reconnecting since the detected scope name would not
      match the expected name generated by virSystemdMakeScopeName.
      
      The error is exposed by the following log entry:
      
      debug : virCgroupValidateMachineGroup:302 : Name 'machine-qemu\x2dtestvm.scope' for controller 'cpu' does not match 'testvm', 'testvm.libvirt-qemu' or 'machine-test-qemu\x2dtestvm.scope'
      
      for a "/machine/test" resource and "testvm" vm.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1238570
      88f6c007
  11. 21 7月, 2015 1 次提交
    • M
      nodedev: add RDMA and tx-udp_tnl-segmentation NIC capabilities · ac3ed208
      Moshe Levi 提交于
      Adding functionality to libvirt that will allow
      it query the interface for the availability of RDMA and
      tx-udp_tnl-segmentation Offloading NIC capabilities
      
      Here is an example of the feature XML definition:
      
      <device>
      <name>net_eth4_90_e2_ba_5e_a5_45</name>
        <path>/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.1/net/eth4</path>
        <parent>pci_0000_08_00_1</parent>
        <capability type='net'>
          <interface>eth4</interface>
          <address>90:e2:ba:5e:a5:45</address>
          <link speed='10000' state='up'/>
          <feature name='rx'/>
          <feature name='tx'/>
          <feature name='sg'/>
          <feature name='tso'/>
          <feature name='gso'/>
          <feature name='gro'/>
          <feature name='rxvlan'/>
          <feature name='txvlan'/>
          <feature name='rxhash'/>
          <feature name='rdma'/>
          <feature name='txudptnl'/>
          <capability type='80203'/>
        </capability>
      </device>
      ac3ed208
  12. 14 7月, 2015 1 次提交
  13. 10 7月, 2015 3 次提交
    • J
      qemu: Don't report false error from MigrateFinish · 44c42b56
      Jiri Denemark 提交于
      virDomainMigrateFinish* APIs were unfortunately designed to return the
      pointer to the domain on destination and NULL on error. This looks OK in
      normal cases but the same API is also called when we know migration
      failed and thus we expect Finish to return NULL even if it actually did
      all it was supposed to do without any error. The call is defined to
      return nonnull domain pointer over RPC, which means returning NULL will
      always result in an error being send. If this was not in fact an error,
      the API itself wouldn't set anything to the thread local virError, which
      makes the RPC layer come up with it's own "Library function returned
      error but did not set virError" error.
      
      This is quite confusing and also hard to detect by the caller. This
      patch adds a special error code which can be used to check that Finish
      successfully aborted migration.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      44c42b56
    • J
      Introduce virErrorCopyNew · 9d0a2af6
      Jiri Denemark 提交于
      A helper function for copying error objects.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      9d0a2af6
    • J
      Introduce virHashAtomic · a7c22a1f
      Jiri Denemark 提交于
      This is a self-locking wrapper around virHashTable. Only a limited set
      of APIs are implemented now (the ones which are used in the following
      patch) as more can be added on demand.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      a7c22a1f
  14. 08 7月, 2015 1 次提交
  15. 02 7月, 2015 4 次提交
  16. 26 6月, 2015 1 次提交
  17. 25 6月, 2015 5 次提交
    • E
      json: enhance parser test · cb005533
      Eric Blake 提交于
      We already enable the parser option to detect invalid UTF-8, but
      didn't test it.  Also, JSON states that behavior of an object
      with a duplicated key is undefined; we chose to reject it, but
      were not testing it.
      
      With the enhanced tests in place, we can simplify yajl2
      initialization by relying on parser defaults being sane.
      
      * src/util/virjson.c (virJSONValueFromString): Simplify.
      * tests/jsontest.c (mymain): Test more bad usage.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cb005533
    • E
      json: even stricter trailing garbage detection · 7e191fd9
      Eric Blake 提交于
      Since older yajl ignores trailing garbage, a client can cause
      problems by intentionally ending the wrapper array early. Since
      we already track nesting, it's not too much harder to reject
      invalid nesting pops.
      
      * src/util/virjson. (_virJSONParser): Add field.
      (virJSONValueFromString): Set witness.
      (virJSONParserHandleEndArray): Use it to catch abuse.
      * tests/jsontest.c (mymain): Test it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7e191fd9
    • E
      json: reject trailing garbage · 7cd991b7
      Eric Blake 提交于
      Yajl 2 has a nice feature that it can be configured whether to
      allow multiple JSON objects parsed from a single stream, defaulting
      to off.  And yajl 1.0.12 at least provided a way to tell if all
      input bytes were parsed, or if trailing bytes remained after a
      valid JSON object was parsed.  But we target RHEL 6 yajl 1.0.7,
      which has neither of these.  So fake it by always parsing '[...]'
      instead, so that trailing garbage either trips up the array parse,
      or is easily detected when unwrapping the result.
      
      * src/util/virjson.c (virJSONValueFromString): With older json,
      wrap text to avoid trailing garbage.
      * tests/jsontest.c (mymain): Add tests for this.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7cd991b7
    • E
      json: reject javascript comments · 54dbba5b
      Eric Blake 提交于
      We have been allowing javascript style comments in JSON ever
      since commit 9428f2ce (v0.7.5), but qemu doesn't send them, and
      they are not strict JSON.  Reject them for now; if we can later
      prove that it is worthwhile, we can reinstate it at that point
      (or even make it conditional, by adding a bool parameter to
      the libvirt entry point).
      
      * src/util/virjson.c (virJSONValueFromString): Don't enable
      comment parsing.
      * tests/jsontest.c (mymain): Test it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      54dbba5b
    • E
      json: cope with older yajl semantics · f2acaebd
      Eric Blake 提交于
      Commit ceb496e5 fails on RHEL 6, with yajl 1.0.7, because that
      version of yajl returns yajl_status_insufficient_data when the
      parser is waiting for the rest of a token (this enum value was
      dropped in yajl 2, so we have to wrap it).  It also exposes a
      problem where older yajl silently ignores trailing garbage after
      a successful parse, so this patch works around that by changing
      the testsuite.  Another more invasive patch can add tighter
      semantics to json parsing, but this is sufficient for a minimal
      clean backport.
      
      While touching this, fix up our error message cleanup. Yajl
      documents that error messages produced by yajl_get_error()
      MUST be cleaned with yajl_free_error(); this is certainly
      true if we were to pass non-NULL allocator callbacks during
      yajl_alloc(), but probably harmless in our usage of passing
      NULL.  But better safe than sorry.
      
      * src/util/virjson.c (virJSONValueFromString): Allow different
      error code.  Use canonical cleanup of error message.
      (VIR_YAJL_STATUS_OK): New helper macro.
      * tests/jsontest.c (mymain): Wrap text to avoid difference in
      trailing garbage handling
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f2acaebd
  18. 23 6月, 2015 4 次提交
    • E
      Convert SCSI logical unit from unsigned int to unsigned long long · 22b8a617
      Eric Farman 提交于
      The SCSI Architecture Model defines a logical unit address
      as 64-bits in length, so change the field accordingly so
      that the entire value could be stored.
      Signed-off-by: NEric Farman <farman@linux.vnet.ibm.com>
      22b8a617
    • E
      Print SCSI address attributes bus, target, unit as unsigned integer · 3b7983ad
      Eric Farman 提交于
      The address elements are all unsigned integers, so we should
      use the appropriate print directive when printing it.
      Signed-off-by: NEric Farman <farman@linux.vnet.ibm.com>
      3b7983ad
    • E
      json: make it easier to type-check when getting from object · 58fd6703
      Eric Blake 提交于
      While working in qemu_monitor_json, I repeatedly found myself
      getting a value then checking if it was an object.  Add some
      wrappers to make this task easier.
      
      * src/util/virjson.c (virJSONValueObjectGetByType)
      (virJSONValueObjectGetObject, virJSONValueObjectGetArray): New
      functions.
      (virJSONValueObjectGetString, virJSONValueObjectGetNumberInt)
      (virJSONValueObjectGetNumberUint)
      (virJSONValueObjectGetNumberLong)
      (virJSONValueObjectGetNumberUlong)
      (virJSONValueObjectGetNumberDouble)
      (virJSONValueObjectGetBoolean): Simplify.
      (virJSONValueIsNull): Change return type.
      * src/util/virjson.h: Reflect changes.
      * src/libvirt_private.syms (virjson.h): Export them.
      * tests/jsontest.c (testJSONLookup): New test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      58fd6703
    • E
      json: fully parse input string · ceb496e5
      Eric Blake 提交于
      I was adding a JSON test, and was shocked to find out our parser
      treated the input string of "1" as invalid JSON.  It turns out
      that YAJL specifically documents that it buffers input, and that
      if the last input read could be a prefix to a longer token, then
      you have to explicitly tell the parser that the buffer has ended
      before that token will be processed.
      
      It doesn't help that yajl 2 renamed the function from what it was
      in yajl 1.
      
      * src/util/virjson.c (virJSONValueFromString): Complete parse, in
      case buffer ends in possible token prefix.
      * tests/jsontest.c (mymain): Expose the problem.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ceb496e5
  19. 18 6月, 2015 2 次提交