1. 13 6月, 2012 2 次提交
    • J
      client rpc: Improve debug messages in virNetClientIO · 71689f95
      Jiri Denemark 提交于
      When analyzing our debug log, I'm always confused about what each of the
      pointers mean. Let's be explicit.
      71689f95
    • E
      build: fix 'make dist' on virgin checkout · 9b5970c6
      Eric Blake 提交于
      'make dist' was depending on *protocol-structs files, which are
      stored in git but in turn depended on generated files.  We still
      want to ship the protocol-structs files, but by renaming the
      tests to something not matching a file name, we separate 'make
      check' (which depends on the generated file) from 'make dist'
      (which only depends on the git files).  After all, the tarball
      should never depend on a generated file not stored in git.
      
      I found one more case of a git file depending on a generated
      file, in a bogus virkeycode.c listing; but at least this one
      had no associated rules so it never broke 'make dist'.
      
      Reported by Wen Congyang.  Latent bug has been present since
      commit 62dee6fa, but only recently exposed by commit 7bff56a0.
      
      * src/Makefile.am ($(srcdir)/util/virkeycode.c): Drop useless
      dependency.
      (BUILT_SOURCES): ...and build virkeymaps.h sooner.
      (PROTOCOL_STRUCTS): Rather than depend on the struct file...
      (check-local): ...convert things into a phony target of...
      (check-protocol): ...a new check.
      ($(srcdir)/remote_protocol-struct): Rename to isolate the distributed
      file from the conditional test.
      (PDWTAGS): Deal with rename.  Swap to compare 'expected actual'.
      9b5970c6
  2. 12 6月, 2012 8 次提交
    • G
      openvz: wire up domainUpdateDeviceFlags · f5d61d39
      Guido Günther 提交于
      so we can update file system quota
      f5d61d39
    • G
      openvz: add persist parameter to openvzSetDiskQuota · 1d82540a
      Guido Günther 提交于
      with persist=false the domain config file will not be updated.
      1d82540a
    • G
      Introduce virDomainFSIndexByName · 0dde544c
      Guido Günther 提交于
      for containers matching virDomainDiskIndexByName.
      0dde544c
    • M
      qemu: Don't overwrite security labels · 86032b22
      Michal Privoznik 提交于
      Currently, if qemuProcessStart fail at some point, e.g. because
      domain being started wants a PCI/USB device already assigned to
      a different domain, we jump to cleanup label where qemuProcessStop
      is performed. This unconditionally calls virSecurityManagerRestoreAllLabel
      which is wrong because the other domain is still using those devices.
      
      However, once we successfully label all devices/paths in
      qemuProcessStart() from that point on, we have to perform a rollback
      on failure - that is - we have to virSecurityManagerRestoreAllLabel.
      86032b22
    • M
      qemuProcessStop: Switch to flags · 69dd7714
      Michal Privoznik 提交于
      Currently, we are passing only one boolean (migrated) so there is
      no real profit in this. But it creates starting position for
      next patch.
      69dd7714
    • E
      snapshot: implement new APIs for qemu · e3559a6e
      Eric Blake 提交于
      The two APIs are rather trivial; based on bits and pieces of other
      existing APIs.  It leaves the door open for future extension to
      qemu to report snapshots without metadata based on reading qcow2
      internal snapshot names.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotIsCurrent)
      (qemuDomainSnapshotHasMetadata): New functions.
      e3559a6e
    • E
      snapshot: RPC for new query APIs · a2bc4a0c
      Eric Blake 提交于
      Pretty straightforward.
      
      * src/remote/remote_protocol.x
      (remote_domain_snapshot_is_current_args)
      (remote_domain_snapshot_is_current_ret)
      (remote_domain_snapshot_has_metadata_args)
      (remote_domain_snapshot_has_metadata_ret): New structs.
      (REMOTE_PROC_DOMAIN_SNAPSHOT_IS_CURRENT)
      (REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA): New RPC calls.
      * src/remote/remote_driver.c (remote_driver): Call them.
      * src/remote_protocol-structs: Regenerate.
      a2bc4a0c
    • E
      snapshot: new query APIs · 2e13b9ab
      Eric Blake 提交于
      Right now, starting from just a virDomainSnapshotPtr, and wanting to
      know if it is the current snapshot for its respective domain, you have
      to use virDomainSnapshotGetDomain(), then virDomainSnapshotCurrent(),
      then compare the two names returned by virDomainSnapshotGetName().
      It is a bit easier if we can directly query this information from the
      snapshot itself.
      
      Right now, it is possible to filter a snapshot listing based on
      whether snapshots have metadata that would prevent domain deletion,
      but the only way to learn if an individual snapshot has metadata is
      to see if that snapshot appears in the list returned by a listing.
      Additionally, I hope to expand the qemu driver in a future patch to
      use qemu-img to reconstruct snapshot XML corresponding to internal
      qcow2 snapshot names not otherwise tracked by libvirt (in part, so
      that libvirt can guarantee that new snapshots are not created with
      a name that would silently corrupt the existing portion of the qcow2
      file); if I ever get that in, then it would no longer be an all-or-none
      decision on whether snapshots have metadata, and becomes all the more
      important to be able to directly determine that information from a
      particular snapshot.
      
      Other query functions (such as virDomainIsActive) do not have a flags
      argument, but since virDomainHasCurrentSnapshot takes a flags argument,
      I figured it was safer to provide a flags argument here as well.
      
      * include/libvirt/libvirt.h.in (virDomainSnapshotIsCurrent)
      (virDomainSnapshotHasMetadata): New declarations.
      * src/libvirt.c (virDomainSnapshotIsCurrent)
      (virDomainSnapshotHasMetadata): New functions.
      * src/libvirt_public.syms (LIBVIRT_0.9.13): Export them.
      * src/driver.h (virDrvDomainSnapshotIsCurrent)
      (virDrvDomainSnapshotHasMetadata): New driver callbacks.
      2e13b9ab
  3. 11 6月, 2012 5 次提交
  4. 09 6月, 2012 2 次提交
  5. 08 6月, 2012 3 次提交
    • J
      util: Fix deadlock in virLogReset · d581313a
      Jiri Denemark 提交于
      When libvirtd forks off a new child, the child then calls virLogReset(),
      which ends up closing file descriptors used as log outputs. However, we
      recently started logging closed file descriptors, which means we need to
      lock logging mutex which was already locked by virLogReset(). We don't
      really want to log anything when we are in the process of closing log
      outputs.
      d581313a
    • C
    • L
      Assign correct address type to spapr-vlan and spapr-vty. · 04a319ba
      Li Zhang 提交于
      For pseries guest, spapr-vlan and spapr-vty is based
      on spapr-vio address. According to model of network
      device, the address type should be assigned automatically.
      For serial device, serial pty device is recognized as
      spapr-vty device, which is also on spapr-vio.
      
      So this patch is to correct the address type of
      spapr-vlan and spapr-vty, and build correct
      command line of spapr-vty.
      Signed-off-by: NLi Zhang <zhlcindy@linux.vnet.ibm.com>
      Reviewed-by:   Michael Ellerman<michaele@au1.ibm.com>
      04a319ba
  6. 07 6月, 2012 3 次提交
    • E
      command: avoid potential deadlock on handshake · 5e8ab391
      Eric Blake 提交于
      There is a theoretical problem of an extreme bug where we can get
      into deadlock due to command handshaking.  Thanks to a pair of pipes,
      we have a situation where the parent thinks the child reported an
      error and is waiting for a message from the child to explain the
      error; but at the same time the child thinks it reported success
      and is waiting for the parent to acknowledge the success; so both
      processes are now blocked.
      
      Thankfully, I don't think this deadlock is possible without at
      least one other bug in the code, but I did see exactly that sort
      of situation prior to commit da831afc - I saw a backtrace where a
      double close bug in the parent caused the parent to read from the
      wrong fd and assume the child failed, even though the child really
      sent success.
      
      This potential deadlock is not quite like commit 858c2476 (a deadlock
      due to multiple readers on one pipe preventing a write from completing),
      although the solution is similar - always close unused pipe fds before
      blocking, rather than after.
      
      * src/util/command.c (virCommandHandshakeWait): Close unused fds
      sooner.
      5e8ab391
    • M
      qemu: better detection of crashed domains · bda2f17d
      Martin Kletzander 提交于
      When libvirtd is started and there is an unusable/not-connectable
      leftover from earlier started machine, it's more reasonable to say
      that the machine "crashed" if we know it was started with
      "-no-shutdown".
      This patch fixes that and also changes the other result (when machine
      was started without "-no-shutdown") to "unknown", because the previous
      "failed" reason means (according to include/libvirt/libvirt.h.in:174),
      that the machine failed to start.
      bda2f17d
    • E
      build: fix build of fresh checkout · ca02b101
      Eric Blake 提交于
      Commit 7bff56a0 worked in an incremental build, but fails for a
      fresh clone; apparently, if make sees both an actual file
      spelling and an inference rule, only the exact spelling is used.
      
        CCLD   libvirt_driver_test.la
        CC     libvirt_driver_remote_la-remote_driver.lo
      remote/remote_driver.c:4707:34: fatal error: remote_client_bodies.h: No such file or directory
      compilation terminated.
      
      BUILT_SOURCES to the rescue, instead of trying to mess with .lo
      dependencies directly.
      
      * src/Makefile.am (REMOTE_DRIVER_PREREQS, %remote_driver.lo): Drop...
      (BUILT_SOURCES): ...and add here instead.
      ca02b101
  7. 06 6月, 2012 1 次提交
    • E
      build: ensure storage driver is used · 3c3644d3
      Eric Blake 提交于
      Commit 1c275e9a accidentally dropped the storage driver from
      libvirtd, because it depended on a C preprocessor macro that
      was not defined.  Furthermore, if you do './configure
      --without-storage-dir --with-storage-disk' or any other combination
      where you explicitly build a subset of storage backends excluding
      the dir backend, then the build is broken.
      
      Based on analysis by Osier Yang.
      
      * configure.ac (WITH_STORAGE): Define top-level conditional.
      * src/Makefile.am (mod_LTLIBRARIES): Build driver even when
      storage_dir is disabled.
      * daemon/libvirtd.c: Pick up storage driver for any backend, not
      just dir.
      * daemon/Makefile.am (libvirtd_LDADD): Likewise.
      3c3644d3
  8. 05 6月, 2012 7 次提交
    • M
      rpc: Size up RPC limits · eb635de1
      Michal Privoznik 提交于
      Since we are allocating RPC buffer dynamically, we can increase limits
      for max. size of RPC message and RPC string. This is needed to cover
      some corner cases where libvirt is run on such huge machines that their
      capabilities XML is 4 times bigger than our current limit. This leaves
      users with inability to even connect.
      eb635de1
    • M
      rpc: Switch to dynamically allocated message buffer · a2c304f6
      Michal Privoznik 提交于
      Currently, we are allocating buffer for RPC messages statically.
      This is not such pain when RPC limits are small. However, if we want
      ever to increase those limits, we need to allocate buffer dynamically,
      based on RPC message len (= the first 4 bytes). Therefore we will
      decrease our mem usage in most cases and still be flexible enough in
      corner cases.
      a2c304f6
    • E
      build: fix 'make distcheck' issues · 7bff56a0
      Eric Blake 提交于
      We had a distributed file (remote_protocol.h, which in turn was
      a prereq to remote_driver.c) depending on a generated file
      (libvirt_probes.h), which is a no-no for a VPATH build from a
      read-only source tree (no wonder 'make distcheck' tests precisely
      that situation):
      
           File `libvirt_driver_remote.la' does not exist.
             File `libvirt_driver_remote_la-remote_driver.lo' does not exist.
                   Prerequisite `libvirt_probes.h' is newer than target `../../src/remote/remote_protocol.h'.
                  Must remake target `../../src/remote/remote_protocol.h'.
      Invoking recipe from Makefile:7464 to update target `../../src/remote/remote_protocol.h'.
      make[3]: Entering directory `/home/remote/eblake/libvirt-tmp2/build/libvirt-0.9.12/_build/src'
        GEN    ../../src/remote/remote_protocol.h
      cannot create ../../src/remote/remote_protocol.h: Permission denied at ../../src/rpc/genprotocol.pl line 31.
      make[3]: *** [../../src/remote/remote_protocol.h] Error 13
      
      Rather than making distributed .c files depend on generated files, we
      really want to ensure that compilation into .lo files is not attempted
      until the generated files are present, done by this patch.  Since there
      were two different sets of conditionally generated files that both
      feed the .lo file, I had to introduce a new variable REMOTE_DRIVER_PREREQS
      to keep automake happy.
      
      After that fix, the next issue was that make treats './foo' and 'foo'
      differently in determining whether an implicit %foo rule is applicable,
      with the result that locking/qemu-sanlock.conf wasn't properly being
      built at the right times.  Also, the output for using the .aug test
      files was a bit verbose.
      
      After fixing the src directory, the next error is related to the docs
      directory, where the tarball is missing a stamp file and thus tries to
      regenerate files that are already present:
      
        GEN    ../../docs/apibuild.py.stamp
      Traceback (most recent call last):
        File "../../docs/apibuild.py", line 2511, in <module>
          rebuild("libvirt")
        File "../../docs/apibuild.py", line 2495, in rebuild
          builder.serialize()
        File "../../docs/apibuild.py", line 2424, in serialize
          output = open(filename, "w")
      IOError: [Errno 13] Permission denied: '../../docs/libvirt-api.xml'
      make[5]: *** [../../docs/apibuild.py.stamp] Error 1
      
      and fixing that exposed another case of a distributed file (generated
      html) depending on a built file (libvirt.h), but only when doing an
      in-tree build, because of a file glob.
      
      * src/Makefile.am ($(srcdir)/remote/remote_driver.c): Change...
      (libvirt_driver_remote_la-remote_driver.lo): ...to the real
      dependency.
      ($(builddir)/locking/%-sanlock.conf): Drop $(builddir), so that
      rule gets run in time for test_libvirt_sanlock.aug.
      (test_libvir*.aug): Cater to silent build.
      (conf_DATA): Don't ship qemu-sanlock.conf in the tarball, since it
      is trivial to regenerate.
      * docs/Makefile.am (EXTRA_DIST): Ship our stamp file.
      ($(APIBUILD_STAMP)): Don't depend on generated file.
      7bff56a0
    • B
      Fix for parallel port passthrough for QEMU · 7508338f
      Beat Jörg 提交于
      I came across a bug that the command line generated for passthrough
      of the host parallel port /dev/parport0 by libvirt for QEMU is incorrect.
      
      It currently produces:
      -chardev tty,id=charparallel0,path=/dev/parport0
      -device isa-parallel,chardev=charparallel0,id=parallel0
      
      The first parameter is "tty". It sould be "parport".
      
      If I launch qemu with -chardev parport,... it works as expected.
      
      I have already filled a bug report (
      https://bugzilla.redhat.com/show_bug.cgi?id=823879 ), the topic was
      already on the list some months ago:
      
      https://www.redhat.com/archives/libvirt-users/2011-September/msg00095.htmlSigned-off-by: NEric Blake <eblake@redhat.com>
      7508338f
    • E
      maint: command.c whitespace cleanups · a3bc393e
      Eric Blake 提交于
      Noticed during the previous commit.
      
      * src/util/command.c: Fix some spacing and break long lines.
      a3bc393e
    • E
      command: avoid deadlock on EPIPE situation · 858c2476
      Eric Blake 提交于
      It is possible to deadlock libvirt by having a domain with XML
      longer than PIPE_BUF, and by writing a hook script that closes
      stdin early.  This is because libvirt was keeping a copy of the
      child's stdin read fd open, which means the write fd in the
      parent will never see EPIPE (remember, libvirt should always be
      run with SIGPIPE ignored, so we should never get a SIGPIPE signal).
      Since there is no error, libvirt blocks waiting for a write to
      complete, even though the only reader is also libvirt.  The
      solution is to ensure that only the child can act as a reader
      before the parent does any writes; and then dealing with the
      fallout of dealing with EPIPE.
      
      Thankfully, this is not a security hole - since the only way to
      trigger the deadlock is to install a custom hook script, anyone
      that already has privileges to install a hook script already has
      privileges to do any number of other equally disruptive things
      to libvirt; it would only be a security hole if an unprivileged
      user could install a hook script to DoS a privileged user.
      
      * src/util/command.c (virCommandRun): Close parent's copy of child
      read fd earlier.
      (virCommandProcessIO): Don't let EPIPE be fatal; the child may
      be done parsing input.
      * tests/commandhelper.c (main): Set up a SIGPIPE situation.
      * tests/commandtest.c (test20): Trigger it.
      * tests/commanddata/test20.log: New file.
      858c2476
    • L
      util: fix "make rpm" when viratomic.h is used · 80e4b166
      Laine Stump 提交于
      Although src/util/viratomic.h has been added to the repo, up until now
      it hasn't been used. Stefan Berger is using it in his proposed dhcp
      snooping patches, and an rpm build with those patches failed due to
      viratomic.h not being packed up with the rest of the sources.
      80e4b166
  9. 04 6月, 2012 3 次提交
  10. 02 6月, 2012 5 次提交
    • S
      nwfilter: Add multiple IP address support to DHCP snooping · b92d52d3
      Stefan Berger 提交于
      With support for multiple IP addresses per interface in place, this patch
      now adds support for multiple IP addresses per interface for the DHCP
      snooping code.
      
      
      Testing:
      
      Since the infrastructure I tested this with does not provide multiple IP
      addresses per MAC address (anymore), I either had to plug the VM's interface
      from the virtual bride connected directly to the infrastructure to virbr0
      to get a 2nd IP address from dnsmasq (kill and run dhclient inside the VM)
      or changed the lease file  (/var/run/libvirt/network/nwfilter.leases) and
      restart libvirtd to have a 2nd IP address on an existing interface.
      Note that dnsmasq can take a lease timeout parameter as part of the --dhcp-range
      command line parameter, so that timeouts can be tested that way
      (--dhcp-range 192.168.122.2,192.168.122.254,120). So, terminating and restarting
      dnsmasq with that parameter is another choice to watch an IP address disappear
      after 120 seconds.
      
      Regards,
         Stefan
      b92d52d3
    • S
      nwfilter: move code for IP address map into separate file · 797b4758
      Stefan Berger 提交于
      The goal of this patch is to prepare for support for multiple IP
      addresses per interface in the DHCP snooping code.
      
      Move the code for the IP address map that maps interface names to
      IP addresses into their own file. Rename the functions on the way
      but otherwise leave the code as-is. Initialize this new layer
      separately before dependent layers (iplearning, dhcpsnooping)
      and shut it down after them.
      797b4758
    • S
      nwfilter: add DHCP snooping · cec281fc
      Stefan Berger 提交于
      This patch adds DHCP snooping support to libvirt. The learning method for
      IP addresses is specified by setting the "CTRL_IP_LEARNING" variable to one of
      "any" [default] (existing IP learning code), "none" (static only addresses)
      or "dhcp" (DHCP snooping).
      
      Active leases are saved in a lease file and reloaded on restart or HUP.
      
      The following interface XML activates and uses the DHCP snooping:
      
          <interface type='bridge'>
            <source bridge='virbr0'/>
            <filterref filter='clean-traffic'>
              <parameter name='CTRL_IP_LEARNING' value='dhcp'/>
            </filterref>
          </interface>
      
      All filters containing the variable 'IP' are automatically adjusted when
      the VM receives an IP address via DHCP. However, multiple IP addresses per
      interface are silently ignored in this patch, thus only supporting one IP
      address per interface. Multiple IP address support is added in a later
      patch in this series.
      Signed-off-by: NDavid L Stevens <dlstevens@us.ibm.com>
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      cec281fc
    • M
      qemu: move -name arg to be 1st in "ps x" output · 195fa214
      Marti Raudsepp 提交于
      Currently, monitoring QEMU virtual machines with standard Unix
      sysadmin tools is harder than it has to be. The QEMU command line is
      often miles long and mostly redundant, it's hard to tell which process
      is which.
      
      This patch reorders the QEMU -name argument to be the first, so it's
      immediately visible in "ps x", htop and "atop -c" output.
      195fa214
    • L
      qemu: fix netdev alias name assignment wrt type='hostdev' · 6734ce7b
      Laine Stump 提交于
      This patch resolves:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=827519
      
      The problem is that an interface with type='hostdev' will have an
      alias of the form "hostdev%d", while the function that looks through
      existing netdevs to determine the name to use for a new addition will
      fail if there's an existing entry that does not match the form
      "net%d".
      
      This is another of the handful of places that need an exception due to
      the hybrid nature of <interface type='hostdev'> (which is not exactly
      an <interface> or a <hostdev>, but is both at the same time).
      6734ce7b
  11. 31 5月, 2012 1 次提交
    • W
      qemu: avoid closing fd more than once · b19c236d
      Wen Congyang 提交于
      If we migrate to fd, spec->fwdType is not MIGRATION_FWD_DIRECT,
      we will close spec->dest.fd.local in qemuMigrationRun(). So we
      should set spec->dest.fd.local to -1 in qemuMigrationRun().
      
      Bug present since 0.9.5 (commit 32617617).
      b19c236d