1. 11 12月, 2012 24 次提交
    • L
      conf: put data for network <forward> element into its own struct · 47c94b65
      Laine Stump 提交于
      The attributes of a <network> element's <forward> element were
      previously stored directly in the virNetworkDef object, but
      virNetworkUpdateForward() needs to operate on a <forward> in
      isolation, so this patchs pulls out all those attributes into a
      separate virNetworkForwardDef struct (and shortens their names
      appropriately). This new object is contained in the virNetworkDef, not
      pointed to by it, so there is no extra memory management.
      
      This patch makes no functional changes, it only changes, e.g.,
      "nForwardIfs" to "forward.nifs".
      47c94b65
    • L
      conf: make virNetworkIpDefClear consistent with other functions · 31d21197
      Laine Stump 提交于
      The other clear functions in network_conf.c that clear out arrays of
      sub-objects do so by using the n[itemname]s value as a counter going
      down to 0. Make this one consistent. There's no functional value, just
      makes the style more consistent with the rest of the file.
      31d21197
    • L
      conf: rename some labels and functions in network_conf · dc9d8d68
      Laine Stump 提交于
      This makes some function names and arg lists for consistent with other
      parse functions in network_conf.c. While modifying
      virNetworkIPParseXML(), also change its "error" label to "cleanup",
      since the code at that label is executed on success as well as
      failure.
      dc9d8d68
    • L
      network: backend functions for updating network dns host/srv/txt · fc19a005
      Laine Stump 提交于
      These three functions are very similar - none allow a MODIFY
      operation; you can only add or delete.
      
      The biggest difference between them (other than the data itself) is in
      the criteria for determining a match, and whether or not multiple
      matches are possible:
      
      1) for HOST records, it's considered a match if the IP address or any
      of the hostnames of an existing record matches.
      
      2) for SRV records, it's a match if all of
      domain+service+protocol+target *which have been specified* are
      matched.
      
      3) for TXT records, there is only a single field to match - name
      (value can be the same for multiple records, and isn't considered a
      search term), so by definition there can be no ambiguous matches.
      
      In all three cases, if any matches are found, ADD will fail; if
      multiple matches are found, it means the search term was ambiguous,
      and a DELETE will fail.
      
      The upper level code in bridge_driver.c is already implemented for
      these functions - appropriate conf files will be re-written, and
      dnsmasq will be SIGHUPed or restarted as appropriate.
      fc19a005
    • L
      conf: clear and parse functions for dns host/srv/txt records · ab297bec
      Laine Stump 提交于
      Since there is only a single virNetworkDNSDef for any virNetworkDef,
      and it's trivial to determine whether or not it contains any real
      data, it's much simpler (and fits more uniformly with the parse
      function calling sequence of the parsers for many other objects that
      are subordinates of virNetworkDef) if virNetworkDef *contains* an
      virNetworkDNSDef rather than pointing to one.
      
      Since it is now just a part of another object rather than its own
      object, it no longer makes sense to have a *Free() function, so that
      is changed to a *Clear() function.
      
      More importantly though, ParseXML and Clear functions are needed for
      the individual items contained in a virNetworkDNSDef (srv, txt, and
      host records), but none of them have a *Clear(), and only two of the
      three had *ParseXML() functions (both of which used a non-uniform
      arglist). Those problems are cleared up by this patch - it splits the
      higher-level Clear function into separate functions for each of the
      three, creates a parse for txt records, and cleans up the srv and host
      parsers, so we now have all the utility functions necessary to
      implement virNetworkDefUpdateDNS(Host|Srv|Txt).
      ab297bec
    • L
      conf: rename network dns host/srv/txt arrays · 8b7d1874
      Laine Stump 提交于
      This shortens the name of the structs for srv and txt, and their
      instances in virNetworkDNSDef, to be more compact and uniform with the
      naming of the dns host array. It also changes the type of ntxts, etc
      from unsigned int to size_t, so that they can be used directly as args
      to VIR_*_ELEMENT.
      8b7d1874
    • L
      conf: use VIR_(INSERT|DELETE)_ELEMENT in virNetworkUpdate backend · 2dc5839a
      Laine Stump 提交于
      The already-written backend functions for virNetworkUpdate that add
      and delete items into lists within the a network were already debugged
      to work properly, but future such functions will use
      VIR_(INSERT|DELETE)_ELEMENT instead, so these are changed for
      uniformity.
      2dc5839a
    • 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
    • P
      qemu: Restart CPUs with valid async job type when doing external snapshots · 46b0c933
      Peter Krempa 提交于
      When restarting CPUs after an external snapshot, the restarting function
      was called without the appropriate async job type. This caused that a
      new sync job wasn't created and allowed races in the monitor.
      46b0c933
    • D
      parallels: add support of removing disks · 84e27a6f
      Dmitry Guryanov 提交于
      If some hard disk is not found in new domain configuration, it
      should be removed.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      84e27a6f
    • D
      parallels: apply config after VM creation · d5c4783c
      Dmitry Guryanov 提交于
      New VM will have default values for all parameters, like
      cpu number, we have to change its configuration as provided
      by xml definition, given to parallelsDomainDefineXML.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      d5c4783c
    • D
      parallels: add support of disks creation · b4f0c19e
      Dmitry Guryanov 提交于
      Implement creation of new disks - if a new disk found
      in configuration, find a volume by disk path and
      actually create a disk image by issuing prlctl command.
      If it's successfully finished - remove the file with volume
      definition.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      b4f0c19e
    • D
      parallels: add function parallelsGetDiskBusName · 592664c1
      Dmitry Guryanov 提交于
      Add function for convertion bus from libvirt's numeric constant
      to a name, used in a parallels command-line tools.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      592664c1
    • D
      parallels: split parallelsStorageVolumeDelete function · 944705e2
      Dmitry Guryanov 提交于
      Move part, which deletes existing volume, to a new function
      parallelsStorageVolumeDefRemove so that we can use it later
      in parallels_driver.c
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      944705e2
    • D
      parallels: fill volumes capacity parameter · a9bd9b94
      Dmitry Guryanov 提交于
      Read disk images size from xml description and fill
      virStorageVolDef.capacity and allocation (let's consider
      that allocation is the same as capacity, calculating real
      allcoation will be implemented later).
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      a9bd9b94
    • D
      parallels: add info about volumes · 9b4c03ae
      Dmitry Guryanov 提交于
      Disk images in Parallels Cloud Server stored in directories. Each
      one has files with data and xml description of an image stored in
      file DiskDescriptior.xml.
      
      Since we have to support 'detached' images, which are not used by
      any VM, the better way to collect info about volumes is searching for
      directories with a file DiskDescriptior.xml in each VM directory.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      9b4c03ae
    • D
      parallels: fix leaks in parallelsFindVolumes · 7abe342d
      Dmitry Guryanov 提交于
      We always have to close opened dir and free 'path'.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      7abe342d
    • D
      parallels: create storage pools by VM list · 766e0c91
      Dmitry Guryanov 提交于
      There are no storage pools in Parallels Cloud Server -
      All VM data stored in a single directory: config, snapshots,
      memory dump together with disk images.
      
      Let's look through list of VMs and create a storage pool for
      each directory, containing VMs.
      
      So if you have 3 vms: /var/parallels/vm-1.pvm,
      /var/parallels/vm-2.pvm and /root/test.pvm - 2 storage pools
      appear: -var-parallels and -root. xml descriptions of the pools
      will be saved in /etc/libvirt/parallels-storage, so UUIDs will
      not change netween connections to libvirt.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      766e0c91
    • D
      parallels: remove unused code from storage driver · 4dc52e1e
      Dmitry Guryanov 提交于
      We don't support unprivileged users anymore, so remove code, which
      selects configuration directory depending on user.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      4dc52e1e
    • D
      parallels: split parallelsStorageOpen function · 21e1bdeb
      Dmitry Guryanov 提交于
      Move code for loading inforation about pools to a separate
      function - parallelsLoadPools.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      21e1bdeb
    • D
      parallels: handle disk devices in parallelsDomainDefineXML · 45e63171
      Dmitry Guryanov 提交于
      Allow changing some parameters of the hard disks: bus,
      image and drive address.
      
      Creating new disk devices and removing existing ones
      require changes in the storage driver, so it will be
      implemented later.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      45e63171
    • D
      parallels: add info about hard disk devices · 6718b2d7
      Dmitry Guryanov 提交于
      Parse information about hard disks and fill disks array
      in virDomainDef structure.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      6718b2d7
    • L
      Add support for offline migration · 8b9bf787
      liguang 提交于
      Offline migration transfers inactive definition of a domain (which may
      or may not be active). After successful completion, the domain remains
      in its current state on source host and is defined but inactive on
      destination host. It's a bit more clever than virDomainGetXMLDesc() on
      source host followed by virDomainDefineXML() on destination host, as
      offline migration will run pre-migration hook to update the domain XML
      on destination host. Currently, copying non-shared storage is not
      supported during offline migration.
      
      Offline migration can be requested with a new migration flag called
      VIR_MIGRATE_OFFLINE (which has to be combined with
      VIR_MIGRATE_PERSIST_DEST flag).
      8b9bf787
    • L
      qemu: eliminate bogus error log when changing netdev's bridge · e5577872
      Laine Stump 提交于
      This fixes a problem that showed up during testing of:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=881480
      
      Due to a logic error in the function that gets the name of the bridge
      an interface connects to, any time a bridge was specified directly
      (type='bridge') rather than indirectly (type='network'), An error
      would be logged (although the operation would then complete
      successfully):
      
         Network type 6 is not supported
      
      The final virReportError() in the function
      qemuDomainNetGetBridgeName() was apparently avoided in the past with a
      "goto cleanup" at the end of each case, but the case of bridge somehow
      no longer has that final goto cleanup.
      
      The proper solution is anyway to not rely on goto's, but put the error
      log inside an else {} clause, so that it's executed only if the type
      is neither bridge nor network (in reality, this function should only
      ever be called for those two types, that's why this is an internal
      error).
      
      While making this change, the error message was also tuned to be more
      correct (since it's not really the type of the network, but the type
      of the interface, and it *is* otherwise supported, it's just that the
      interface type in question doesn't *have* a bridge device associated
      with it, or at least we don't know how to get it).
      e5577872
  2. 10 12月, 2012 2 次提交
  3. 08 12月, 2012 1 次提交
  4. 07 12月, 2012 8 次提交
    • P
      virsh: Fix usage of header termios.h · 989a427d
      Peter Krempa 提交于
      The termios struct exported by the termios.h header is used as an
      argument for vshMakeStdinRaw(). The header isn't used anywhere in
      tools/virsh-domain.c.
      
      This patch adds the header to the header declaring vshMakeStdinRaw() and
      removes other places in virsh.
      989a427d
    • J
      virsh: allow metadata preallocation when creating volumes · 790dfee5
      Ján Tomko 提交于
      Add --prealloc-metadata flag to these commands:
      vol-clone
      vol-create
      vol-create-as
      vol-create-from
      790dfee5
    • J
      storage: allow metadata preallocation when creating qcow2 images · 1c9a2fb1
      Ján Tomko 提交于
      Add VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA flag to virStorageVolCreateXML
      and virStorageVolCreateXMLFrom. This flag requests metadata
      preallocation when creating/cloning qcow2 images, resulting in creating
      a sparse file with qcow2 metadata. It has only slightly larger disk usage
      compared to new image with no allocation, but offers higher performance.
      1c9a2fb1
    • O
      qemu: Allow the user to specify vendor and product for disk · b718ded3
      Osier Yang 提交于
      QEMU supports setting vendor and product strings for disk since
      1.2.0 (only scsi-disk, scsi-hd, scsi-cd support it), this patch
      exposes it with new XML elements <vendor> and <product> of disk
      device.
      b718ded3
    • J
      Convert libxl driver to Xen 4.2 · dfa1e1dd
      Jim Fehlig 提交于
      Based on a patch originally authored by Daniel De Graaf
      
        http://lists.xen.org/archives/html/xen-devel/2012-05/msg00565.html
      
      This patch converts the Xen libxl driver to support only Xen >= 4.2.
      Support for Xen 4.1 libxl is dropped since that version of libxl is
      designated 'technology preview' only and is incompatible with Xen 4.2
      libxl.  Additionally, the default toolstack in Xen 4.1 is still xend,
      for which libvirt has a stable, functional driver.
      dfa1e1dd
    • G
      Inhibit daemon shutdown during driver initialization · 6856b937
      Guido Günther 提交于
      As of 1a50ba2c qemu capabilities probing
      takes longer since we timeout waiting for the monitor socket. When
      probing qemu for different architectures this can add up so the daemon
      auto shutdown timeout is reached and the client doesn't have a chance
      to connect. To avoid that inhibit daemon shutdown during driver
      initialization (which includes capabilities probing).
      
      This fixes
      
      	http://honk.sigxcpu.org:8001/job/libvirt-tck-debian-wheezy-qemu-session/227/
      6856b937
    • C
      util: Don't fail virGetGroupIDByName when group not found · a33f4eae
      Christophe Fergeau 提交于
      virGetGroupIDByName is documented as returning 1 if the groupname
      cannot be found. getgrnam_r is documented as returning:
      « 0 or ENOENT or ESRCH or EBADF or EPERM or ...  The given name
      or gid was not found. »
       and that:
      « The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
      It  does  not  call  "not  found"  an error, hence does not specify what
      value errno might have in this situation.  But that makes it impossible to
      recognize errors.  One might argue that according to POSIX errno should be
      left unchanged if an entry is not found.  Experiments on various UNIX-like
      systems shows that lots of different values occur in this situation: 0,
      ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others. »
      
      virGetGroupIDByName returns an error when the return value of getgrnam_r
      is non-0. However on my RHEL system, getgrnam_r returns ENOENT when the
      requested user cannot be found, which then causes virGetGroupID not
      to behave as documented (it returns an error instead of falling back
      to parsing the passed-in value as an gid).
      
      This commit makes virGetGroupIDByName only report an error when errno
      is set to one of the values in the posix description of getgrnam_r
      (which are the same as the ones described in the manpage on my system).
      a33f4eae
    • C
      util: Don't fail virGetUserIDByName when user not found · 6c6c03dc
      Christophe Fergeau 提交于
      virGetUserIDByName is documented as returning 1 if the username
      cannot be found. getpwnam_r is documented as returning:
      « 0 or ENOENT or ESRCH or EBADF or EPERM or ...  The given name
      or uid was not found. »
       and that:
      « The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
      It  does  not  call  "not  found"  an error, hence does not specify what
      value errno might have in this situation.  But that makes it impossible to
      recognize errors.  One might argue that according to POSIX errno should be
      left unchanged if an entry is not found.  Experiments on various UNIX-like
      systems shows that lots of different values occur in this situation: 0,
      ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others. »
      
      virGetUserIDByName returns an error when the return value of getpwnam_r
      is non-0. However on my RHEL system, getpwnam_r returns ENOENT when the
      requested user cannot be found, which then causes virGetUserID not
      to behave as documented (it returns an error instead of falling back
      to parsing the passed-in value as an uid).
      
      This commit makes virGetUserIDByName only report an error when errno
      is set to one of the values in the posix description of getpwnam_r
      (which are the same as the ones described in the manpage on my system).
      6c6c03dc
  5. 06 12月, 2012 5 次提交
    • M
      dnsmasq: Fix parsing of the version number · ff33f807
      Michal Privoznik 提交于
      If debugging is enabled, the debug messages are sent to stderr.
      Moreover, if a command has catching of stderr set, the messages
      gets mixed with stdout output (assuming both outputs are stored
      in the same variable). The resulting string then doesn't
      necessarily have to start with desired prefix then. This bug
      exposes itself when parsing dnsmasq output:
      
      2012-12-06 11:18:11.445+0000: 18491: error :
      dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
      /usr/sbin/dnsmasq version number in '2012-12-06
      11:11:02.232+0000: 18492: debug : virFileClose:72 : Closed fd 22'
      
      We can clearly see that the output of dnsmasq --version doesn't
      start with expected "Dnsmasq version " string but a libvirt debug
      output.
      ff33f807
    • M
      dnsmasq: Fix parsing of the version number · 51144313
      Michal Privoznik 提交于
      If the debugging is enabled, the virCommand subsystem catches debug
      messages in the command output as well. In that case, we can't assume
      the string corresponding to command's stdout will start with specific
      prefix. But the prefix can be moved deeper in the string. This bug
      shows itself when parsing dnsmasq output:
      
      2012-12-06 11:18:11.445+0000: 18491: error :
      dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
      /usr/sbin/dnsmasq version number in '2012-12-06 11:11:02.232+0000:
      18492: debug : virFileClose:72 : Closed fd 22'
      
      We can clearly see that the output of dnsmasq --version
      doesn't start with expected "Dnsmasq version " string but a libvirt
      debug output.
      51144313
    • 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
    • G
      network: allow guest to guest IPv6 without gateway definition · 705e67d4
      Gene Czarcinski 提交于
      This patch adds the capability for virtual guests to do IPv6
      communication via a virtual network interface with no IPv6 (gateway)
      addresses specified.  This capability has always been enabled by
      default for IPv4, but disabled for IPv6 for security concerns, and
      because it requires the ip6tables command to be operational (which
      isn't the case on a system with the ipv6 module completely disabled).
      
      This patch adds a new attribute "ipv6" at the toplevel of a <network>
      object.  If ipv6='yes', the extra ip6tables rules required to permite
      inter-guest communications are added when the network is started. If
      it is 'no', or not present, those rules will not be added; thus the
      default behavior doesn't change, so there should be no compatibility
      issues with any existing installations.
      
      Note that virtual guests cannot communication with the virtualization
      host via this interface, because the following kernel tunable has
      been set:
      
         net.ipv6.conf.<bridge_interface_name>.disable_ipv6 = 1
      
      This assures that the bridge interface will not have an IPv6
      link-local (fe80::) address.
      
      To control this behavior so that it is not enabled by default, the parameter
      ipv6='yes' on the <network> statement has been added.
      
      Documentation related to this patch has been updated.
      The network schema has also been updated.
      705e67d4
    • O
      storage: Error out earlier if the volume target path already exists · d1f3d149
      Osier Yang 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=832302
      
      It's odd to fall through to buildVol, and the existed file is
      removed when buildVol fails. This checks if the volume target
      path already exists in createVol. The reason for not using
      error like "Volume already exists" is that there isn't volume
      maintained by libvirt for the path until a operation like
      pool-refresh, using error like that will just cause confusion.
      d1f3d149