1. 26 1月, 2013 1 次提交
    • E
      conf: avoid NULL deref for pmsuspended domain state · e0642059
      Eric Blake 提交于
      While working with a pmsuspend vs. snapshot issue, I noticed that
      the state file in /var/run/libvirt/qemu/dom.xml contained a rather
      suspicious "(null)" string, which does not round-trip well through
      a libvirtd restart.  Had I been on a platform other than glibc
      where printf("%s",NULL) crashes instead of printing (null), we might
      have noticed the problem much sooner.
      
      And in fixing that problem, I also noticed that we had several
      missing states, because we were #defining several *_LAST names
      to a value _different_ than what they were already given as enums
      in libvirt.h.  Yuck.  I got rid of default: labels in the case
      statements, because they get in the way of gcc's -Wswitch helping
      us ensure we cover all enum values.
      
      * src/conf/domain_conf.c (virDomainStateReasonToString)
      (virDomainStateReasonFromString): Fill in missing domain states;
      rewrite case statement to let compiler enforce checking.
      (VIR_DOMAIN_NOSTATE_LAST, VIR_DOMAIN_RUNNING_LAST)
      (VIR_DOMAIN_BLOCKED_LAST, VIR_DOMAIN_PAUSED_LAST)
      (VIR_DOMAIN_SHUTDOWN_LAST, VIR_DOMAIN_SHUTOFF_LAST)
      (VIR_DOMAIN_CRASHED_LAST): Drop dead defines.
      (VIR_DOMAIN_PMSUSPENDED_LAST): Drop dead define.
      (virDomainPMSuspendedReason): Add missing enum function.
      (virDomainRunningReason, virDomainPausedReason): Add missing enum
      value.
      * src/conf/domain_conf.h (virDomainPMSuspendedReason): Declare
      missing functions.
      * src/libvirt_private.syms (domain_conf.h): Export them.
      e0642059
  2. 25 1月, 2013 1 次提交
    • E
      maint: make it easier to sort syms files · f0aa4935
      Eric Blake 提交于
      I got bit by 'make check' complaining that the sort order I got
      by emacs' sort-lines function differed from expectations.
      
      * src/libvirt_private.syms: Add emacs trailer.
      * src/libvirt_atomic.syms: Likewise.
      * src/libvirt_daemon.syms: Likewise.
      * src/libvirt_esx.syms: Likewise.
      * src/libvirt_libssh2.syms: Likewise.
      * src/libvirt_linux.syms: Likewise.
      * src/libvirt_openvz.syms: Likewise.
      * src/libvirt_sasl.syms: Likewise.
      * src/libvirt_vmx.syms: Likewise.
      * src/libvirt_xenxs.syms: Likewise.
      f0aa4935
  3. 24 1月, 2013 1 次提交
    • P
      capabilities: Switch CPU data in NUMA topology to a struct · 87b4c10c
      Peter Krempa 提交于
      This will allow storing additional topology data in the NUMA topology
      definition.
      
      This patch changes the storage type and fixes fallout of the change
      across the drivers using it.
      
      This patch also changes semantics of adding new NUMA cell information.
      Until now the data were re-allocated and copied to the topology
      definition. This patch changes the addition function to steal the
      pointer to a pre-allocated structure to simplify the code.
      87b4c10c
  4. 18 1月, 2013 1 次提交
  5. 16 1月, 2013 4 次提交
  6. 10 1月, 2013 1 次提交
    • G
      qemu: add usb-serial support · e3a04455
      Guannan Ren 提交于
      Add an optional 'type' attribute to <target> element of serial port
      device. There are two choices for its value, 'isa-serial' and
      'usb-serial'. For backward compatibility, when attribute 'type' is
      missing the 'isa-serial' will be chosen as before.
      
      Libvirt XML sample
      
          <serial type='pty'>
            <target type='usb-serial' port='0'/>
            <address type='usb' bus='0' port='1'/>
          </serial>
      
      qemu commandline:
      
      qemu ${other_vm_args}              \
          -chardev pty,id=charserial0    \
          -device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1
      e3a04455
  7. 08 1月, 2013 1 次提交
  8. 07 1月, 2013 2 次提交
    • O
      qemu: set unpriv_sgio when starting domain and attaching disk · 278f87c4
      Osier Yang 提交于
      This ignores the default "filtered" if unpriv_sgio is not supported
      by kernel, but for explicit request "filtered", it error out for
      domain starting.
      278f87c4
    • O
      util: Prepare helpers for unpriv_sgio setting · ba72cb12
      Osier Yang 提交于
      "virGetDeviceID" could be used across the sources, but it doesn't
      relate with this series, and could be done later.
      
      * src/util/virutil.h: (Declare virGetDeviceID, and
                             vir{Get,Set}DeviceUnprivSGIO)
      * src/util/virutil.c: (Implement virGetDeviceID and
                             vir{Get,Set}DeviceUnprivSGIO)
      * src/libvirt_private.syms: Export private symbols of upper helpers
      ba72cb12
  9. 05 1月, 2013 3 次提交
  10. 21 12月, 2012 1 次提交
  11. 19 12月, 2012 1 次提交
  12. 18 12月, 2012 2 次提交
    • D
      Add support for <hostdev mode="capabilities"> · aae0fc2a
      Daniel P. Berrange 提交于
      The <hostdev> device type has long had a redundant "mode"
      attribute, which has always been "subsys". This finally
      introduces a new mode "capabilities", which will be used
      by the LXC driver for device assignment. Since container
      based virtualization uses a single kernel, the idea of
      assigning physical PCI devices doesn't make sense. It is
      still reasonable to assign USB devices, but for assigning
      arbitrary nodes in /dev, the new 'capabilities' mode is
      to be used.
      
      The first capability support is 'storage', which is for
      assignment of block devices. Functionally this is really
      pretty similar to the <disk> support. The only difference
      is the device node name is identical in both host and
      container namespaces.
      
          <hostdev mode='capabilities' type='storage'>
            <source>
              <block>/dev/sdf1</block>
            </source>
          </hostdev>
      
      The second capability support is 'misc', which is for
      assignment of character devices. There is no existing
      parallel to this. Again the device node is the same
      inside & outside the container.
      
          <hostdev mode='capabilities' type='misc'>
            <source>
              <char>/dev/input/event3</char>
            </source>
          </hostdev>
      
      The reason for keeping the char & storage devices
      separate in the domain XML, is to mirror the split
      in the node device XML. NB the node device XML does
      not yet report character devices, but that's another
      new patch to come
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      aae0fc2a
    • V
      S390: Fix virSysinfoRead memory corruption · cab938c9
      Viktor Mihajlovski 提交于
      There was a double free issue caused by virSysinfoRead on s390,
      as the same manufacturer string instance was assigned to more
      than one processor record.
      Cleaned up other potential memory issues and restructured the sysinfo
      parsing code by moving repeating patterns into a helper function.
      
      The restructuring made it necessary to conditionally disable
      -Wlogical-op for some older GCC versions, using pragma GCC diagnostic.
      This is a GCC specific pragma, which is acceptable, since we're
      using it to work around a GCC specific bug.
      
      Finally, added a function virSysinfoSetup to configure the sysinfo
      data source files/script during run time, to facilitate writing test
      programs. This function is not published in sysinfo.h and only
      there for testing.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      cab938c9
  13. 12 12月, 2012 5 次提交
  14. 11 12月, 2012 1 次提交
    • L
      util: add VIR_(APPEND|INSERT|DELETE)_ELEMENT · 85b22f52
      Laine Stump 提交于
      I noticed when writing the backend functions for virNetworkUpdate that
      I was repeating the same sequence of memmove, VIR_REALLOC, nXXX-- (and
      messed up the args to memmove at least once), and had seen the same
      sequence in a lot of other places, so I decided to write a few
      utility functions/macros - see the .h file for full documentation.
      
      The intent is to reduce the number of lines of code, but more
      importantly to eliminate the need to check the element size and
      element count arithmetic every time we need to do this (I *always*
      make at least one mistake.)
      
      VIR_INSERT_ELEMENT: insert one element at an arbitrary index within an
        array of objects. The size of each object is determined
        automatically by the macro using sizeof(*array). The new element's
        contents are copied into the inserted space, then the original copy
        of contents are 0'ed out (if everything else was
        successful). Compile-time assignment and size compatibility between
        the array and the new element is guaranteed (see explanation below
        [*])
      
      VIR_INSERT_ELEMENT_COPY: identical to VIR_INSERT_ELEMENT, except that
        the original contents of newelem are not cleared to 0 (i.e. a copy
        is made).
      
      VIR_APPEND_ELEMENT: This is just a special case of VIR_INSERT_ELEMENT
        that "inserts" one past the current last element.
      
      VIR_APPEND_ELEMENT_COPY: identical to VIR_APPEND_ELEMENT, except that
        the original contents of newelem are not cleared to 0 (i.e. a copy
        is made).
      
      VIR_DELETE_ELEMENT: delete one element at an arbitrary index within an
        array of objects. It's assumed that the element being deleted is
        already saved elsewhere (or cleared, if that's what is appropriate).
      
      All five of these macros have an _INPLACE variant, which skips the
      memory re-allocation of the array, assuming that the caller has
      already done it (when inserting) or will do it later (when deleting).
      
      Note that VIR_DELETE_ELEMENT* can return a failure, but only if an
      invalid index is given (index + amount to delete is > current array
      size), so in most cases you can safely ignore the return (that's why
      the helper function virDeleteElementsN isn't declared with
      ATTRIBUTE_RETURN_CHECK). A warning is logged if this ever happens,
      since it is surely a coding error.
      
      [*] One initial problem with the INSERT and APPEND macros was that,
      due to both the array pointer and newelem pointer being cast to void*
      when passing to virInsertElementsN(), any chance of type-checking was
      lost. If we were going to move in newelem with a memmove anyway, we
      would be no worse off for this. However, most current open-coded
      insert/append operations use direct struct assignment to move the new
      element into place (or just populate the new element directly) - thus
      use of the new macros would open a possibility for new usage errors
      that didn't exist before (e.g. accidentally sending &newelemptr rather
      than newelemptr - I actually did this quite a lot in my test
      conversions of existing code).
      
      But thanks to Eric Blake's clever thinking, I was able to modify the
      INSERT and APPEND macros so that they *do* check for both assignment
      and size compatibility of *ptr (an element in the array) and newelem
      (the element being copied into the new position of the array). This is
      done via clever use of the C89-guaranteed fact that the sizeof()
      operator must have *no* side effects (so an assignment inside sizeof()
      is checked for validity, but not actually evaluated), and the fact
      that virInsertElementsN has a "# of new elements" argument that we
      want to always be 1.
      85b22f52
  15. 07 12月, 2012 1 次提交
  16. 06 12月, 2012 1 次提交
    • L
      network: prevent a few invalid configuration combinations · fd54f1de
      Laine Stump 提交于
      This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=767057
      
      It was possible to define a network with <forward mode='bridge'> that
      had both a bridge device and a forward device defined. These two are
      mutually exclusive by definition (if you are using a bridge device,
      then this is a host bridge, and if you have a forward dev defined,
      this is using macvtap). It was also possible to put <ip>, <dns>, and
      <domain> elements in this definition, although those aren't supported
      by the current driver (although it's conceivable that some other
      driver might support that).
      
      The items that are invalid by definition, are now checked in the XML
      parser (since they will definitely *always* be wrong), and the others
      are checked in networkValidate() in the network driver (since, as
      mentioned, it's possible that some other network driver, or even this
      one, could some day support setting those).
      fd54f1de
  17. 05 12月, 2012 1 次提交
  18. 04 12月, 2012 3 次提交
    • D
      Replace polling for active VMs with signalling by drivers · 79b8a569
      Daniel P. Berrange 提交于
      Currently to deal with auto-shutdown libvirtd must periodically
      poll all stateful drivers. Thus sucks because it requires
      acquiring both the driver lock and locks on every single virtual
      machine. Instead pass in a "inhibit" callback to virStateInitialize
      which drivers can invoke whenever they want to inhibit shutdown
      due to existance of active VMs.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      79b8a569
    • L
      qemu: support live update of an interface's filter · 258fb278
      Laine Stump 提交于
      Since we can't (currently) rely on the ability to provide blanket
      support for all possible network changes by calling the toplevel
      netdev hostside disconnect/connect functions (due to qemu only
      supporting a lockstep between initialization of host side and guest
      side of devices), in order to support live change of an interface's
      nwfilter we need to make a special purpose function to only call the
      nwfilter teardown and setup functions if the filter for an interface
      (or its parameters) changes. The pattern is nearly identical to that
      used to change the bridge that an interface is connected to.
      
      This patch was inspired by a request from Guido Winkelmann
      <guido@sagersystems.de>, who tested an earlier version.
      258fb278
    • S
      nwfilter: utility function virNWFilterVarValueEqual · ab4139a4
      Stefan Berger 提交于
      To detect if an interface's nwfilter has changed, we need to also
      compare the filterparams, which is a hashtable of virNWFilterVarValue.
      virHashEqual can do this nicely, but requires a pointer to a function
      that will compare two of the items being stored in the hashes.
      ab4139a4
  19. 01 12月, 2012 2 次提交
  20. 30 11月, 2012 2 次提交
    • L
      util: new virSocketAddrIsPrivate function · bf402e77
      Laine Stump 提交于
      This new function returns true if the given address is in the range of
      any "private" or "local" networks as defined in RFC1918 (IPv4) or
      RFC3484/RFC4193 (IPv6), otherwise they return false.
      
      These ranges are:
      
         192.168.0.0/16
         172.16.0.0/16
         10.0.0.0/24
         FC00::/7
         FEC0::/10
      bf402e77
    • L
      util: capabilities detection for dnsmasq · 719c2c76
      Laine Stump 提交于
      In order to optionally take advantage of new features in dnsmasq when
      the host's version of dnsmasq supports them, but still be able to run
      on hosts that don't support the new features, we need to be able to
      detect the version of dnsmasq running on the host, and possibly
      determine from the help output what options are in this dnsmasq.
      
      This patch implements a greatly simplified version of the capabilities
      code we already have for qemu. A dnsmasqCaps device can be created and
      populated either from running a program on disk, reading a file with
      the concatenated output of "dnsmasq --version; dnsmasq --help", or
      examining a buffer in memory that contains the concatenated output of
      those two commands. Simple functions to retrieve capabilities flags,
      the version number, and the path of the binary are also included.
      
      bridge_driver.c creates a single dnsmasqCaps object at driver startup,
      and disposes of it at driver shutdown. Any time it must be used, the
      dnsmasqCapsRefresh method is called - it checks the mtime of the
      binary, and re-runs the checks if the binary has changed.
      
      networkxml2argvtest.c creates 2 "artificial" dnsmasqCaps objects at
      startup - one "restricted" (doesn't support --bind-dynamic) and one
      "full" (does support --bind-dynamic). Some of the test cases use one
      and some the other, to make sure both code pathes are tested.
      719c2c76
  21. 28 11月, 2012 3 次提交
  22. 27 11月, 2012 2 次提交
    • H
      qemu: Add support for gluster protocol based network storage backend. · c33c36d2
      Harsh Prateek Bora 提交于
      Qemu accepts gluster protocol as supported storage backend beside others.
      Signed-off-by: NHarsh Prateek Bora <harsh@linux.vnet.ibm.com>
      c33c36d2
    • H
      Add Gluster protocol as supported network disk backend · a2d2b80f
      Harsh Prateek Bora 提交于
      This patch introduces the RNG schema and updates necessary data strucutures
      to allow various hypervisors to make use of Gluster protocol as one of the
      supported network disk backend. Next patch will add support to make use of
      this feature in Qemu since it now supports Gluster protocol as one of the
      network based storage backend.
      
      Two new optional attributes for <host> element are introduced - 'transport'
      and 'socket'. Valid transport values are tcp, unix or rdma. If none specified,
      tcp is assumed. If transport is unix, socket specifies path to unix socket.
      
      This patch allows users to specify disks on gluster backends like this:
      
          <disk type='network' device='disk'>
            <driver name='qemu' type='raw'/>
            <source protocol='gluster' name='Volume1/image'>
              <host name='example.org' port='6000' transport='tcp'/>
            </source>
            <target dev='vda' bus='virtio'/>
          </disk>
      
          <disk type='network' device='disk'>
            <driver name='qemu' type='raw'/>
            <source protocol='gluster' name='Volume2/image'>
              <host transport='unix' socket='/path/to/sock'/>
            </source>
            <target dev='vdb' bus='virtio'/>
          </disk>
      Signed-off-by: NHarsh Prateek Bora <harsh@linux.vnet.ibm.com>
      a2d2b80f