1. 10 12月, 2012 37 次提交
    • P
      lxc: Avoid segfault of libvirt_lxc helper on early cleanup paths · fac1a19d
      Peter Krempa 提交于
      Early jumps to the cleanup label caused a crash of the libvirt_lxc
      container helper as the cleanup section called
      virLXCControllerDeleteInterfaces(ctrl) without checking the ctrl argument
      for NULL. The argument was de-referenced soon after.
      
      $ /usr/libexec/libvirt_lxc
      /usr/libexec/libvirt_lxc: missing --name argument for configuration
      Segmentation fault
      (cherry picked from commit 81efb13b)
      fac1a19d
    • J
      storage: fix logical volume cloning · 89cecbbe
      Ján Tomko 提交于
      Commit 258e06c8 removed setting of the volume type to
      VIR_STORAGE_VOL_BLOCK, which leads to failures in
      storageVolumeCreateXMLFrom.
      
      The type (and target.format) of the volume was set to zero. In
      virStorageBackendGetBuildVolFromFunction, this gets interpreted as
      VIR_STORAGE_FILE_NONE and the qemu-img tool is called with unknown
      "none" format.
      
      Bug: https://bugzilla.redhat.com/show_bug.cgi?id=879780
      (cherry picked from commit 70f0bbe8)
      89cecbbe
    • D
      Skip deleted timers when calculting next timeout · 1f45a323
      Daniel P. Berrange 提交于
      It is possible for there to be deleted timers when we
      calculate the next timeout, and they must be skipped.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit afbd9667)
      1f45a323
    • D
      Warn if requesting update to non-existent timer/handle watch · 9d239b59
      Daniel P. Berrange 提交于
      The event code is a no-op if requested to update a non-existent
      timer/handle watch. This makes it hard to detect bugs in the
      caller who have passed bogus data. Add a VIR_WARN output in
      such cases, since the API does not allow for return errors.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 39064f0f)
      9d239b59
    • D
      Fix virDiskNameToIndex to actually ignore partition numbers · f45dded0
      Daniel P. Berrange 提交于
      The docs for virDiskNameToIndex claim it ignores partition
      numbers. In actual fact though, a code ordering bug means
      that a partition number will cause the code to accidentally
      multiply the result by 26.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 81d6c4de)
      f45dded0
    • M
      conf: Report sensible error for invalid disk name · 17921668
      Martin Kletzander 提交于
      The error "... but the cause is unknown" appeared for XMLs similar to
      this:
      
       <disk type='file' device='cdrom'>
         <driver name='qemu' type='raw'/>
         <source file='/dev/zero'/>
         <target dev='sr0'/>
       </disk>
      
      Notice unsupported disk type (for the driver), but also no address
      specified. The first part is not a problem and we should not abort
      immediately because of that, but the combination with the address
      unknown was causing an unspecified error.
      
      While fixing this, I added an error to one place where this return
      value was not managed properly.
      (cherry picked from commit 03cd6e4a)
      17921668
    • D
      Use virNetServerRun instead of custom main loop · adc0bc4c
      Daniel P. Berrange 提交于
      The LXC controller code currently directly invokes the
      libvirt main loop code. The problem is that this misses
      the cleanup of virNetServerClient connections that
      virNetServerRun takes care of.
      
      The result is that when libvirtd is stopped, the
      libvirt_lxc controller process gets stuck in a I/O loop.
      When libvirtd is then started again, it fails to connect
      to the controller and thus kills off the entire domain.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit f33e43c2)
      adc0bc4c
    • O
      storage: Fix bug of fs pool destroying · 8b656700
      Osier Yang 提交于
      Regression introduced by commit 258e06c8, "ret" could be set to 1
      or 0 by virStorageBackendFileSystemIsMounted before goto cleanup.
      This could mislead the callers (up to the public API
      virStoragePoolDestroy) to return success even the underlying umount
      command fails.
      (cherry picked from commit f4ac0656)
      8b656700
    • J
      conf: add support for booting from redirected USB devices · 2484fb2e
      Ján Tomko 提交于
      Commit a4c19459 only added the
      QEMU capability flag, command line option and added the boot element
      for redirdev's in the XML schema.
      
      This patch adds support for parsing and writing the XML with redirdevs
      with the boot flag. It also ignores unknown XML elements in redirdev
      instead of failing with:
      "error: An error occurred, but the cause is unknown"
      
      Bug: https://bugzilla.redhat.com/show_bug.cgi?id=805414
      (cherry picked from commit cc244e24)
      2484fb2e
    • L
      qemu: allow larger discrepency between memory & currentMemory in domain xml · b300c71f
      Laine Stump 提交于
      This resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=873134
      
      The reported problem is that an attempt to restore a saved domain that
      was configured with <currentMemory> and <memory> set to some (same for
      both) number that's not a multiple of 4096KiB results in an error like
      this:
      
        error: Failed to start domain libvirt_test_api
        error: XML error: current memory '4001792k' exceeds maximum '4000768k'
      
      (in this case, currentMemory was set to 4000000KiB).
      
      The reason for this failure is:
      
      1) a saved image contains the "live xml" of the domain at the time of
      the save.
      
      2) the live xml of a running domain gets its currentMemory
      (a.k.a. cur_balloon) directly from the qemu monitor rather than from
      the configuration of the domain.
      
      3) the value reported by qemu is (sometimes) not exactly what was
      originally given to qemu when the domain was started, but is rounded
      up to [some indeterminate granularity] - in some versions of qemu that
      granularity is apparently 1MiB, and in others it is 4MiB.
      
      4) When the XML is parsed to setup the state of the restored domain,
      the XML parser for <currentMemory> compares it to <memory> (which is
      the maximum allowed memory size for the domain) and if <currentMemory>
      is greater than the next 1024KiB boundary above <memory>, it spits out
      an error and fails.
      
      For example (from the BZ) if you start qemu on RHEL6 with both
      <currentMemory> and <memory> of 4000000 (this number is in KiB),
      libvirt's dominfo or dumpxml will report "4001792" back (rounded up to
      next 4MiB) for 10-20 seconds after the start, then revert to reporting
      "4000000". On Fedora 16 (which uses qemu-1.0), it will instead report
      "4000768" (rounded up to next 1MiB). On Fedora 17 (qemu-1.2), it seems
      to always report "4000000". ("4000000" is of course okay, and
      "4000768" is also okay since that's the next 1024KiB boundary above
      "4000000" and the parser was already allowing for that. But "4001792
      is *not* okay and produces the error message.)
      
      This patch solves the problem by changing the allowed "fudge factor"
      when parsing from 1024KiB to 4096KiB to match the maximum up-rounding
      that could be done in qemu.
      
      (I had earlier thought to fix this by up-rounding <memory> in the
      dumpxml that's put into the saved image, but that wouldn't have fixed
      the case where the save image was produced by an "unfixed"
      libvirtd.)
      (cherry picked from commit 89204fca)
      b300c71f
    • E
      nodeinfo: support kernels that lack socket information · ddf4a85d
      Eric Blake 提交于
      On RHEL 5, I was getting a segfault trying to start libvirtd,
      because we were failing virNodeParseSocket but not checking
      for errors, and then calling CPU_SET(-1, &sock_map) as a result.
      But if you don't have a topology/physical_package_id file,
      then you can just assume that the cpu belongs to socket 0.
      
      * src/nodeinfo.c (virNodeGetCpuValue): Change bool into
      default_value.
      (virNodeParseSocket): Allow for default value when file is missing,
      different from fatal error on reading file.
      (virNodeParseNode): Update call sites to fail on error.
      (cherry picked from commit 47976b48)
      ddf4a85d
    • J
      ec48fd7d
    • D
      Doug Goldstein gained commit capability · c18efc8e
      Daniel Veillard 提交于
      (cherry picked from commit bf60b6b3)
      c18efc8e
    • E
      build: rerun bootstrap if AUTHORS is missing · 74aaec03
      Eric Blake 提交于
      Ever since commit 7b21981c started generating AUTHORS, we now have
      the situation that if you flip between two branches in the same
      git repository that cross that commit boundary, then 'make' will
      fail due to automake complaining about AUTHORS not existing.  The
      simplest solution is to realize that if AUTHORS does not exist,
      then we flipped branches so we will need to rerun bootstrap
      anyways; and rerunning bootstrap ensures AUTHORS will exist in time.
      
      * cfg.mk (_update_required): Also depend on AUTHORS.
      (cherry picked from commit 71d12562)
      74aaec03
    • D
      Fix uninitialized variable in virLXCControllerSetupDevPTS · caea7122
      Daniel P. Berrange 提交于
      The lack of initialization of 'opts' caused a SEGV in the
      cleanup: path if the root->src directory did not exist
      (cherry picked from commit 3782814d)
      caea7122
    • M
      qemu: Don't force port=0 for SPICE · 3186eb05
      Michal Privoznik 提交于
      If domain uses only TLS port we don't want to add
      'port=0' explicitly to command line.
      (cherry picked from commit 9f872472)
      3186eb05
    • G
      Fix "virsh create" example · d070eee1
      Guido Günther 提交于
      We require a file and don't accept standard input:
      
      http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692322
      (cherry picked from commit d49adae2)
      d070eee1
    • M
      esx: Yet another connection fix for 5.1 · 245c8135
      Martin Kletzander 提交于
      After the connection to ESX 5.1 being broken since g1e7cd395, the fix
      in bab7752c helped a bit, but still missed a spot, so the connection
      is now successful, but some APIs (for example defineXML) don't work.
      Two cases missing are added in this patch to avoid that.
      (cherry picked from commit 9c294e6f)
      245c8135
    • M
      qemu: Add controllers in specified order · e1cb1c06
      Michal Privoznik 提交于
      qemu is sensitive to the order of arguments passed. Hence, if a
      device requires a controller, the controller cmd string must
      precede device cmd string. The same apply for controllers, when
      for instance ccid controller requires usb controller. So
      controllers create partial ordering in which they should be added
      to qemu cmd line.
      (cherry picked from commit 0f720ab3)
      e1cb1c06
    • M
      qemu: Wrap controllers code into dummy loop · a2e51ac0
      Michal Privoznik 提交于
      which just re-indent code and prepare it for next patch.
      (cherry picked from commit 77b93dbc)
      a2e51ac0
    • V
      spec: replace scriptlets with new systemd macros · 77b780f5
      Václav Pavlín 提交于
      https://bugzilla.redhat.com/850186
      
      I added %with_systemd_macros so it should now work in F17 with old
      scriptlets and in F18+/RHEL7+ with systemd macros
      (see https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd)
      
      I missed libvirt-guests.service because there is no systemctl call for
      it. So I only added systemd macros calls.
      (cherry picked from commit ec02d49d)
      77b780f5
    • M
      iohelper: Don't report errors on special FDs · b222c47b
      Michal Privoznik 提交于
      Some FDs may not implement fdatasync() functionality,
      e.g.  pipes. In that case EINVAL or EROFS is returned.
      We don't want to fail then nor report any error.
      Reported-by: NChristophe Fergeau <cfergeau@redhat.com>
      (cherry picked from commit 46325e51)
      b222c47b
    • P
      qemu: Fix possible race when pausing guest · beb086f6
      Peter Krempa 提交于
      When pausing the guest while migration is running (to speed up
      convergence) the virDomainSuspend API checks if the migration job is
      active before entering the job. This could cause a possible race if the
      virDomainSuspend is called while the job is active but ends before the
      Suspend API enters the job (this would require that the migration is
      aborted). This would cause a incorrect event to be emitted.
      (cherry picked from commit d0fc6dc8)
      beb086f6
    • P
      net: Remove dnsmasq and radvd files also when destroying transient nets · d3fd6176
      Peter Krempa 提交于
      The network driver didn't care about config files when a network was
      destroyed, just when it was undefined leaving behind files for transient
      networks.
      
      This patch splits out the cleanup code to a helper function that handles
      the cleanup if the inactive network object is being removed and re-uses
      this code when getting rid of inactive networks.
      (cherry picked from commit e87af617)
      d3fd6176
    • P
      net: Move creation of dnsmasq hosts file to function starting dnsmasq · b16a4ca9
      Peter Krempa 提交于
      The hosts file was created in the network definition function. This
      patch moves the place the file is being created to the point where
      dnsmasq is being started.
      (cherry picked from commit 23ae3fe4)
      b16a4ca9
    • P
      conf: net: Fix deadlock if assignment of network def fails · 2d49ed5d
      Peter Krempa 提交于
      When the assignment fails, the network object is not unlocked and next
      call that would use it deadlocks.
      (cherry picked from commit f8230891)
      2d49ed5d
    • P
      conf: net: Fix helper for applying new network definition · 43995ddc
      Peter Krempa 提交于
      When there's no new definition the helper overwrote the old one with
      NULL.
      (cherry picked from commit 947230fb)
      43995ddc
    • D
      Linux Containers are not allowed to create device nodes. · 9a543041
      Dan Walsh 提交于
      This needs to be done before the container starts. Turning
      off the mknod capability is noticed by systemd, which will
      no longer attempt to create device nodes.
      
      This eliminates SELinux AVC messages and ugly failure messages in the journal.
      (cherry picked from commit 2e03b08e)
      9a543041
    • M
      net-update docs: s/domain/network/ · d676b742
      Michal Privoznik 提交于
      A leftover from copy paste.
      (cherry picked from commit d1236faa)
      d676b742
    • M
      iohelper: fdatasync() at the end · 8a95078f
      Michal Privoznik 提交于
      Currently, when we are doing (managed) save, we insert the
      iohelper between the qemu and OS. The pipe is created, the
      writing end is passed to qemu and the reading end to the
      iohelper. It reads data and write them into given file. However,
      with write() being asynchronous data may still be in OS
      caches and hence in some (corner) cases, all migration data
      may have been read and written (not physically though). So
      qemu will report success, as well as iohelper. However, with
      some non local filesystems, where ENOSPACE is polled every X
      time units, we may get into situation where all operations
      succeeded but data hasn't reached the disk. And in fact will
      never do. Therefore we ought sync caches to make sure data
      has reached the block device on remote host.
      (cherry picked from commit f32e3a2d)
      8a95078f
    • M
      qemu: Fix EmulatorPinInfo without emulatorpin · ec3f5cad
      Martin Kletzander 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=871312
      
      Recent fixes made almost all the right steps to make emulator pinned
      to the cpuset of the whole domain in case <emulatorpin> isn't
      specified, but qemudDomainGetEmulatorPinInfo still reports all the
      CPUs even when cpuset is specified.  This patch fixes that.
      (cherry picked from commit 10c5212b)
      ec3f5cad
    • G
      bugfix: ip6tables rule removal · c3cc4c18
      Gene Czarcinski 提交于
      Three FORWARD chain rules are added and two INPUT chain rules
      are added when a network is started but only the FORWARD chain
      rules are removed when the network is destroyed.
      (cherry picked from commit adaa7ab6)
      c3cc4c18
    • G
      0004a118
    • L
      util: do a better job of matching up pids with their binaries · 58320848
      Laine Stump 提交于
      This patch resolves: https://bugzilla.redhat.com/show_bug.cgi?id=871201
      
      If libvirt is restarted after updating the dnsmasq or radvd packages,
      a subsequent "virsh net-destroy" will fail to kill the dnsmasq/radvd
      process.
      
      The problem is that when libvirtd restarts, it re-reads the dnsmasq
      and radvd pidfiles, then does a sanity check on each pid it finds,
      including checking that the symbolic link in /proc/$pid/exe actually
      points to the same file as the path used by libvirt to execute the
      binary in the first place. If this fails, libvirt assumes that the
      process is no longer alive.
      
      But if the original binary has been replaced, the link in /proc is set
      to "$binarypath (deleted)" (it literally has the string " (deleted)"
      appended to the link text stored in the filesystem), so even if a new
      binary exists in the same location, attempts to resolve the link will
      fail.
      
      In the end, not only is the old dnsmasq/radvd not terminated when the
      network is stopped, but a new dnsmasq can't be started when the
      network is later restarted (because the original process is still
      listening on the ports that the new process wants).
      
      The solution is, when the initial "use stat to check for identical
      inodes" check for identity between /proc/$pid/exe and $binpath fails,
      to check /proc/$pid/exe for a link ending with " (deleted)" and if so,
      truncate that part of the link and compare what's left with the
      original binarypath.
      
      A twist to this problem is that on systems with "merged" /sbin and
      /usr/sbin (i.e. /sbin is really just a symlink to /usr/sbin; Fedora
      17+ is an example of this), libvirt may have started the process using
      one path, but /proc/$pid/exe lists a different path (indeed, on F17
      this is the case - libvirtd uses /sbin/dnsmasq, but /proc/$pid/exe
      shows "/usr/sbin/dnsmasq"). The further bit of code to resolve this is
      to call virFileResolveAllLinks() on both the original binarypath and
      on the truncated link we read from /proc/$pid/exe, and compare the
      results.
      
      The resulting code still succeeds in all the same cases it did before,
      but also succeeds if the binary was deleted or replaced after it was
      started.
      (cherry picked from commit 7bafe009)
      58320848
    • V
      qemu: pass -usb and usb hubs earlier, so USB disks with static address are handled properly · d8199361
      Vladislav Bogdanov 提交于
      (cherry picked from commit 81af5336)
      
      Conflicts:
      	tests/qemuxml2argvdata/qemuxml2argv-bios.args
      	tests/qemuxml2argvdata/qemuxml2argv-disk-copy_on_read.args
      	tests/qemuxml2argvdata/qemuxml2argv-disk-ioeventfd.args
      	tests/qemuxml2argvdata/qemuxml2argv-event_idx.args
      	tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
      	tests/qemuxml2argvdata/qemuxml2argv-virtio-lun.args
      d8199361
    • V
      qemu: Do not ignore address for USB disks · 3f3d0944
      Vladislav Bogdanov 提交于
      (cherry picked from commit 8f708761)
      3f3d0944
    • M
      esx: Fix connection to ESX 5.1 · b29534a6
      Martin Kletzander 提交于
      After separating 5.x and 5.1 versions of ESX, we forgot to add 5.1
      into the list of allowed connections, so connections to 5.1 fail since
      v1.0.0-rc1-5-g1e7cd395
      (cherry picked from commit bab7752c)
      b29534a6
  2. 04 12月, 2012 1 次提交
    • L
      conf: fix virDomainNetGetActualDirect*() and BridgeName() · 48aaabd9
      Laine Stump 提交于
      This resolves:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=881480
      
      These three functions:
      
        virDomainNetGetActualBridgeName
        virDomainNetGetActualDirectDev
        virDomainNetGetActualDirectMode
      
      return attributes that are in a union whose contents are interpreted
      differently depending on the actual->type and so they should only
      return non-0 when actual->type is 'bridge' (in the first case) or
      'direct' (in the other two cases, but I had neglected to do that, so
      ...DirectDev() was returning bridge.brname (which happens to share the
      same spot in the union with direct.linkdev) if actual->type was
      'bridge', and ...BridgeName was returning direct.linkdev when
      actual->type was 'direct'.
      
      How does this involve Bug 881480 (which was about the inability to
      switch between two networks that both have "<forward mode='bridge'/>
      <bridge name='xxx'/>"? Whenever the return value of
      virDomainNetGetActualDirectDev() for the new and old network
      definitions doesn't match, qemuDomainChangeNet() requires a "complete
      reconnect" of the device, which qemu currently doesn't
      support. ...DirectDev() *should* have been returning NULL for old and
      new, but was instead returning the old and new bridge names, which
      differ.
      
      (The other two functions weren't causing any behavioral problems in
      virDomainChangeNet(), but their problem and fix was identical, so I
      included them in this same patch).
      (cherry picked from commit 3738cf41)
      48aaabd9
  3. 30 11月, 2012 2 次提交
    • L
      network: use dnsmasq --bind-dynamic when available · 3fbab08a
      Laine Stump 提交于
      This bug resolves CVE-2012-3411, which is described in the following
      bugzilla report:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=833033
      
      The following report is specifically for libvirt on Fedora:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=874702
      
      In short, a dnsmasq instance run with the intention of listening for
      DHCP/DNS requests only on a libvirt virtual network (which is
      constructed using a Linux host bridge) would also answer queries sent
      from outside the virtualization host.
      
      This patch takes advantage of a new dnsmasq option "--bind-dynamic",
      which will cause the listening socket to be setup such that it will
      only receive those requests that actually come in via the bridge
      interface. In order for this behavior to actually occur, not only must
      "--bind-interfaces" be replaced with "--bind-dynamic", but also all
      "--listen-address" options must be replaced with a single
      "--interface" option. Fully:
      
         --bind-interfaces --except-interface lo --listen-address x.x.x.x ...
      
      (with --listen-address possibly repeated) is replaced with:
      
         --bind-dynamic --interface virbrX
      
      Of course libvirt can't use this new option if the host's dnsmasq
      doesn't have it, but we still want libvirt to function (because the
      great majority of libvirt installations, which only have mode='nat'
      networks using RFC1918 private address ranges (e.g. 192.168.122.0/24),
      are immune to this vulnerability from anywhere beyond the local subnet
      of the host), so we use the new dnsmasqCaps API to check if dnsmasq
      supports the new option and, if not, we use the "old" option style
      instead. In order to assure that this permissiveness doesn't lead to a
      vulnerable system, we do check for non-private addresses in this case,
      and refuse to start the network if both a) we are using the old-style
      options, and b) the network has a publicly routable IP
      address. Hopefully this will provide the proper balance of not being
      disruptive to those not practically affected, and making sure that
      those who *are* affected get their dnsmasq upgraded.
      
      (--bind-dynamic was added to dnsmasq in upstream commit
      54dd393f3938fc0c19088fbd319b95e37d81a2b0, which was included in
      dnsmasq-2.63)
      3fbab08a
    • L
      util: new virSocketAddrIsPrivate function · 337efad9
      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
      337efad9