1. 14 10月, 2013 9 次提交
    • D
      Initialize threading & error layer in LXC controller · 97973ebb
      Daniel P. Berrange 提交于
      In Fedora 20, libvirt_lxc crashes immediately at startup with a
      trace
      
       #0  0x00007f0cddb653ec in free () from /lib64/libc.so.6
       #1  0x00007f0ce0e16f4a in virFree (ptrptr=ptrptr@entry=0x7f0ce1830058) at util/viralloc.c:580
       #2  0x00007f0ce0e2764b in virResetError (err=0x7f0ce1830030) at util/virerror.c:354
       #3  0x00007f0ce0e27a5a in virResetLastError () at util/virerror.c:387
       #4  0x00007f0ce0e28858 in virEventRegisterDefaultImpl () at util/virevent.c:233
       #5  0x00007f0ce0db47c6 in main (argc=11, argv=0x7fff4596c328) at lxc/lxc_controller.c:2352
      
      Normally virInitialize calls virErrorInitialize and
      virThreadInitialize, but we don't link to libvirt.so
      in libvirt_lxc, and nor did we ever call the error
      or thread initializers.
      
      I have absolutely no idea how this has ever worked, let alone
      what caused it to stop working in Fedora 20.
      
      In addition not all code paths from virLogSetFromEnv will
      ensure virLogInitialize is called correctly, which is another
      possible crash scenario.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      97973ebb
    • D
      Don't ignore all dbus connection errors · 6bd88600
      Daniel P. Berrange 提交于
      Previous commit
      
        commit 7ada155c
        Author: Gao feng <gaofeng@cn.fujitsu.com>
        Date:   Wed Sep 11 11:15:02 2013 +0800
      
          DBus: introduce virDBusIsServiceEnabled
      
      Made the cgroups code fallback to non-systemd based setup
      when dbus is not running. It was too big a hammer though,
      as it did not check what error code was received when the
      dbus connection failed. Thus it silently ignored serious
      errors from dbus such as "too many client connections",
      which should always be treated as fatal.
      
      We only want to ignore errors if the dbus unix socket does
      not exist, or if nothing is listening on it.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      6bd88600
    • D
      Improve error reporting with LXC controller · 1815e2d0
      Daniel P. Berrange 提交于
      The LXC code would read the log file if an LXC guest failed to
      startup. There were a number of failure cases where the guest
      will not start and libvirtd never gets as far as looking at the
      log file.
      
      Fix this by replacing some earlier generic errors with messages
      from the log.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      1815e2d0
    • D
      Fix exit status of lxc controller · 13c011c3
      Daniel P. Berrange 提交于
      The LXC controller main() method initialized 'rc' to 1
      rather than '-1'. In the cleanup path it will print any
      error to stderr, if-and-only-if rc < 0. Hence the incorrect
      initialization caused errors to be lost.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      13c011c3
    • D
      Fix flaw in detecting log format · 5787f0b9
      Daniel P. Berrange 提交于
      The log message regex has been
      
      [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug|info|warning|error :
      
      The precedence of '|' is high though, so this is equivalent to matching
      
         [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug
      
      Or
      
         info
      
      Or
      
         warning
      
      Or
      
         error :
      
      Which is clearly not what it should have done. This caused the code to
      skip over things which are not log messages. The solution is to simply
      add brackets.
      
      A test case is also added to validate correctness.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      5787f0b9
    • D
      Make LXC controller use a private dbus connection & close it · ae9a0485
      Daniel P. Berrange 提交于
      The LXC controller uses dbus to talk to systemd to create
      cgroups. This means that each LXC controller instance has
      a dbus connection. The DBus daemon is limited to 256
      connections by default and we want to be able to run many
      1000 of containers.
      
      While the dbus limit could be raised in the config files,
      it is simpler to make libvirt LXC controller close its
      dbus connection once everything is configured.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      ae9a0485
    • D
      Add a method for closing the dbus system bus connection · 489beb0a
      Daniel P. Berrange 提交于
      If the dbus system bus connection is marked as private, then
      allow it to be closed.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      489beb0a
    • D
      Allow use of a private dbus bus connection · 0cb774f0
      Daniel P. Berrange 提交于
      The dbus_bus_get() function returns a shared bus connection that
      all libraries in a process can use. You are forbidden from calling
      close on this connection though, since you can never know if any
      other code might be using it.
      
      Add an option to use private dbus bus connections, if the app
      wants to be able to close the connection.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      0cb774f0
    • C
      lxc: Fix an improper comment in lxc_process.c · 2c9ccd1e
      Chen Hanxiao 提交于
      Fix the improper comment for the "release" hook.
      Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
      2c9ccd1e
  2. 11 10月, 2013 17 次提交
    • H
      nwfilter: fix a typo in nwfilter_gentech_driver.c · 3a49c34a
      Hongwei Bi 提交于
      s/occcurred/occurred
      3a49c34a
    • D
      rpc: Fix getsockopt on Snow Leopard and lower · 2f776d49
      Doug Goldstein 提交于
      Since 5a468b38 we use SOL_LOCAL for the 2nd argument of getsockopt()
      however Lion added the define SOL_LOCAL set to 0, which is the value to
      the 2nd argument of getsockopt() for Unix sockets on Mac OS X. So
      instead of using the define just pass 0 so we restore compatibility
      with Snow Leopard and Leopard.
      
      Reported at https://github.com/mxcl/homebrew/pull/23141
      2f776d49
    • D
      VMware: Do version detection earlier · fa23f9fc
      Doug Goldstein 提交于
      Do VMware version detection earlier as future patches will need the
      version information to populate capabilities correctly.
      fa23f9fc
    • D
      VMware: Simplify array walk for driver type · 9e7cfcb7
      Doug Goldstein 提交于
      Rather than walking the possible driver backends by handle, use a helper
      function. Additionally I've done a bit of refactoring in the code over
      the past few commits so add myself to the copyright line.
      9e7cfcb7
    • M
      qemu: Include listenAddress in debug prints · be651860
      Michal Privoznik 提交于
      After my patches, some functions gained one more argument
      (@listenAddress) which wasn't included in debug printing of
      arguments they were called with. Functions in question are:
      qemuMigrationPrepareDirect and qemuMigrationPerform.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      be651860
    • M
      qemu_migration: Avoid crashing if domain dies too quickly · c7ac2519
      Michal Privoznik 提交于
      I've noticed a SIGSEGV-ing libvirtd on the destination when the qemu
      died too quickly = in Prepare phase. What is happening here is:
      
      1) [Thread 3493] We are in qemuMigrationPrepareAny() and calling
      qemuProcessStart() which subsequently calls qemuProcessWaitForMonitor()
      and qemuConnectMonitor(). So far so good. The qemuMonitorOpen()
      succeeds, however switching monitor to QMP mode fails as qemu died
      meanwhile. That is qemuMonitorSetCapabilities() returns -1.
      
      2013-10-08 15:54:10.629+0000: 3493: debug : qemuMonitorSetCapabilities:1356 : mon=0x14a53da0
      2013-10-08 15:54:10.630+0000: 3493: debug : qemuMonitorJSONCommandWithFd:262 : Send command '{"execute":"qmp_capabilities","id":"libvirt-1"}' for write with FD -1
      2013-10-08 15:54:10.630+0000: 3493: debug : virEventPollUpdateHandle:147 : EVENT_POLL_UPDATE_HANDLE: watch=17 events=13
      ...
      2013-10-08 15:54:10.631+0000: 3493: debug : qemuMonitorSend:956 : QEMU_MONITOR_SEND_MSG: mon=0x14a53da0 msg={"execute":"qmp_capabilities","id":"libvirt-1"}
       fd=-1
      2013-10-08 15:54:10.631+0000: 3262: debug : virEventPollRunOnce:641 : Poll got 1 event(s)
      
      2) [Thread 3262] The event loop is trying to do the talking to monitor.
      However, qemu is dead already, remember?
      
      2013-10-08 15:54:13.436+0000: 3262: error : qemuMonitorIORead:551 : Unable to read from monitor: Connection reset by peer
      2013-10-08 15:54:13.516+0000: 3262: debug : virFileClose:90 : Closed fd 25
      ...
      2013-10-08 15:54:13.533+0000: 3493: debug : qemuMonitorSend:968 : Send command resulted in error internal error: early end of file from monitor: possible problem:
      
      3) [Thread 3493] qemuProcessStart() failed. No big deal. Go to the
      'endjob' label and subsequently to the 'cleanup'. Since the domain is
      not persistent and ret is -1, the qemuDomainRemoveInactive() is called.
      This has an (unpleasant) effect of virObjectUnref()-in the @vm object.
      Unpleasant because the event loop which is about to trigger EOF callback
      still holds a pointer to the @vm (not the reference). See the valgrind
      output below.
      
      4) [Thread 3262] So the event loop starts triggering EOF:
      
      2013-10-08 15:54:13.542+0000: 3262: debug : qemuMonitorIO:729 : Triggering EOF callback
      2013-10-08 15:54:13.543+0000: 3262: debug : qemuProcessHandleMonitorEOF:294 : Received EOF on 0x14549110 'migt10'
      
      And the monitor is cleaned up. This results in calling
      qemuProcessHandleMonitorEOF with the @vm pointer passed. The pointer is
      kept in qemuMonitor struct.
      
      ==3262== Thread 1:
      ==3262== Invalid read of size 4
      ==3262==    at 0x77ECCAA: pthread_mutex_lock (in /lib64/libpthread-2.15.so)
      ==3262==    by 0x52FAA06: virMutexLock (virthreadpthread.c:85)
      ==3262==    by 0x52E3891: virObjectLock (virobject.c:320)
      ==3262==    by 0x11626743: qemuProcessHandleMonitorEOF (qemu_process.c:296)
      ==3262==    by 0x11642593: qemuMonitorIO (qemu_monitor.c:730)
      ==3262==    by 0x52BD526: virEventPollDispatchHandles (vireventpoll.c:501)
      ==3262==    by 0x52BDD49: virEventPollRunOnce (vireventpoll.c:648)
      ==3262==    by 0x52BBC68: virEventRunDefaultImpl (virevent.c:274)
      ==3262==    by 0x542D3D9: virNetServerRun (virnetserver.c:1112)
      ==3262==    by 0x11F368: main (libvirtd.c:1513)
      ==3262==  Address 0x14549128 is 24 bytes inside a block of size 136 free'd
      ==3262==    at 0x4C2AF5C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==3262==    by 0x529B1FF: virFree (viralloc.c:580)
      ==3262==    by 0x52E3703: virObjectUnref (virobject.c:270)
      ==3262==    by 0x531557E: virDomainObjListRemove (domain_conf.c:2355)
      ==3262==    by 0x1160E899: qemuDomainRemoveInactive (qemu_domain.c:2061)
      ==3262==    by 0x1163A0C6: qemuMigrationPrepareAny (qemu_migration.c:2450)
      ==3262==    by 0x1163A923: qemuMigrationPrepareDirect (qemu_migration.c:2626)
      ==3262==    by 0x11682D71: qemuDomainMigratePrepare3Params (qemu_driver.c:10309)
      ==3262==    by 0x53B0976: virDomainMigratePrepare3Params (libvirt.c:7266)
      ==3262==    by 0x1502D3: remoteDispatchDomainMigratePrepare3Params (remote.c:4797)
      ==3262==    by 0x12DECA: remoteDispatchDomainMigratePrepare3ParamsHelper (remote_dispatch.h:5741)
      ==3262==    by 0x54322EB: virNetServerProgramDispatchCall (virnetserverprogram.c:435)
      
      The mon->vm is set in qemuMonitorOpenInternal() which is the correct
      place to increase @vm ref counter. The correct place to decrease the ref
      counter is then qemuMonitorDispose().
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      c7ac2519
    • B
      util: fix two virCompareLimitUlong bugs · 19e7c04d
      Bing Bu Cao 提交于
      The helper function virCompareLimitUlong compares limit values,
      where value of 0 is equal to unlimited. If the latter parameter is 0,
      it should return -1 instead of 1, hence the user can only set hard_limit when
      swap_hard_limit currently is unlimited.
      
      Worse, all callers pass 2 64-bit values, but on 32-bit platforms,
      the second argument was silently truncated to 32 bits, which
      could lead to incorrect computations.
      Signed-off-by: NBing Bu Cao <mars@linux.vnet.ibm.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      19e7c04d
    • D
      Move virNetDevVPort enum impl into virnetdevvportprofile.c · 1fb4d892
      Daniel P. Berrange 提交于
      The enum for virNetDevVPort is declared in the header file
      virnetdevvportprofile.h, but for some reason the impl is
      in netdev_vport_profile_conf.c.
      
      This causes a dep from src/util onto src/conf which is not
      allowed. Move the enum impl into virnetdevvportprofile.c
      to break the circle.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      1fb4d892
    • M
      qemu_conf: Introduce "migration_address" · 1606d89c
      Michal Privoznik 提交于
      This configuration knob is there to override default listen address for
      -incoming for all qemu domains.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      1606d89c
    • M
    • M
      virsocket: Introduce virSocketAddrIsWildcard · 1f9546e3
      Michal Privoznik 提交于
      This function takes exactly one argument: an address to check.
      It returns true, if the address is an IPv4 or IPv6 address in numeric
      format, false otherwise (e.g. for "examplehost").
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      1f9546e3
    • M
      Migration: Introduce VIR_MIGRATE_PARAM_LISTEN_ADDRESS · 72aafe9c
      Michal Privoznik 提交于
      The parameter allows overriding default listen address for '-incoming'
      cmd line argument on destination.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      72aafe9c
    • M
      qemu: Introduce qemuDomainDefCheckABIStability · 7d704812
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=994364
      
      Whenever we check for ABI stability, we have new xml (e.g. provided by
      user, or obtained from snapshot, whatever) which we compare to old xml
      and see if ABI won't break. However, if the new xml was produced via
      virDomainGetXMLDesc(..., VIR_DOMAIN_XML_MIGRATABLE) it lacks some
      devices, e.g. 'pci-root' controller. Hence, the ABI stability check
      fails even though it is stable. Moreover, we can't simply fix
      virDomainDefCheckABIStability because removing the correct devices is
      task for the driver. For instance, qemu driver wants to remove the usb
      controller too, while LXC driver doesn't. That's why we need special
      qemu wrapper over virDomainDefCheckABIStability which removes the
      correct devices from domain XML, produces MIGRATABLE xml and calls the
      check ABI stability function.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      7d704812
    • M
      c643b64e
    • M
      370a7a79
    • M
      ec7005d3
    • M
      qemumonitorjsontest: Extend the test for yet another monitor commands · fbc3adc9
      Michal Privoznik 提交于
      So far, we're unit testing some basic functions and some (so called)
      simple functions (e.g. "qmp_capabilities", "system_powerdown"). However,
      there are more functions which expect simple "{'return': {}}" reply, but
      takes more args to construct the command (for instance "set_link"). This
      patch aims on such functions.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      fbc3adc9
  3. 10 10月, 2013 7 次提交
    • J
      storage_backend: Fix issue with allocation of 0 length volume · 77fb4c4f
      John Ferlan 提交于
      Commit id '532fef36' added a call to fallocate() and some error
      handling based on whether or not the function existed. This new
      call resulted in libvirt-cim/cimtest failures when attempting to
      create a volume with "0" (zero) allocation value. The failure is
      logged as:
      
      Oct  9 07:51:33 localhost libvirtd[8030]: cannot allocate 0 bytes in
      file '/var/lib/libvirt/images/cimtest-vol.img': Invalid argument
      
      This can also be seen with virsh vol-create-as:
      
      error: Failed to create vol test
      error: cannot allocate 0 bytes in file '/home/vm-images/test': Invalid
      argument
      
      error: Failed to create vol test
      error: cannot allocate 0 bytes in file '/home/vm-images/test': Invalid
      argument
      
      It turns out fallocate() will return EINVAL when the incoming 'len'
      (or allocation) value is 0 (or less).
      77fb4c4f
    • M
      qemu: Init @pcidevs in qemuPrepareHostdevPCIDevices · 9c228e08
      Michal Privoznik 提交于
      At the beginning of the function qemuPrepareHostdevPCICheckSupport() is
      called. After that @pcidevs is initialized. However, if the very first
      command fails, we go to 'cleanup' label where virObjectUnref(pcidevs) is
      called. Obviously, it is called before @pcidevs was able to get
      initialized. Compiler warns about it:
      
        CC       qemu/libvirt_driver_qemu_impl_la-qemu_hostdev.lo
      qemu/qemu_hostdev.c: In function 'qemuPrepareHostdevPCIDevices':
      qemu/qemu_hostdev.c:824:19: error: 'pcidevs' may be used uninitialized in this function [-Werror=maybe-uninitialized]
           virObjectUnref(pcidevs);
                         ^
      cc1: all warnings being treated as errors
      9c228e08
    • P
      qemu: Prefer VFIO for PCI device passthrough · f094aaac
      Peter Krempa 提交于
      Prefer using VFIO (if available) to the legacy KVM device passthrough.
      
      With this patch a PCI passthrough device without the driver configured
      will be started with VFIO if it's available on the host. If not legacy
      KVM passthrough is checked and error is reported if it's not available.
      f094aaac
    • P
      qemu: hostdev: Add checks if PCI passthrough is available in the host · 467b561a
      Peter Krempa 提交于
      Add code to check availability of PCI passhthrough using VFIO and the
      legacy KVM passthrough and use it when starting VMs and hotplugging
      devices to live machine.
      467b561a
    • P
      f24150b1
    • P
      qemu: refactor qemuCompressProgramAvailable() · a863b890
      Peter Krempa 提交于
      a863b890
    • P
      qemu: Fix coding style in qemuDomainSaveFlags() · f2b0a533
      Peter Krempa 提交于
      Avoid mixed brace style in an if statement and fix formatting of error
      messages.
      f2b0a533
  4. 09 10月, 2013 5 次提交
    • J
      LXC: Fix handling of RAM filesystem size units · 3f029fb5
      Ján Tomko 提交于
      Since 76b644c3 when the support for RAM filesystems was introduced,
      libvirt accepted the following XML:
      <source usage='1024' unit='KiB'/>
      
      This was parsed correctly and internally stored in bytes, but it
      was formatted as (with an extra 's'):
      <source usage='1024' units='KiB'/>
      When read again, this was treated as if the units were missing,
      meaning libvirt was unable to parse its own XML correctly.
      
      The usage attribute was documented as being in KiB, but it was not
      scaled if the unit was missing. Transient domains still worked,
      because this was balanced by an extra 'k' in the mount options.
      
      This patch:
      Changes the parser to use 'units' instead of 'unit', as the latter
      was never documented (fixing persistent domains) and some programs
      (libvirt-glib, libvirt-sandbox) already parse the 'units' attribute.
      
      Removes the extra 'k' from the tmpfs mount options, which is needed
      because now we parse our own XML correctly.
      
      Changes the default input unit to KiB to match documentation, fixing:
      https://bugzilla.redhat.com/show_bug.cgi?id=1015689
      3f029fb5
    • C
      cgroup: fix a comment typo in vircgroup.c · fc9a416d
      Chen Hanxiao 提交于
      s/shoule/should
      Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
      fc9a416d
    • J
      storage: Use bool instead of int · 63b6e59f
      Ján Tomko 提交于
      Commit 532fef36 added two-state 'need_alloc' and exposed
      'want_sparse' which also only has two states.
      
      Change their type from int to bool.
      63b6e59f
    • C
      tests: Add qemu test for multiple timers · 039eb532
      Cole Robinson 提交于
      The following XML is the recommended default clock configuration for
      qemu:
      
        <clock offset='utc'>
          <timer name='rtc' tickpolicy='catchup'/>
          <timer name='pit' tickpolicy='delay'/>
          <timer name='hpet' present='no'/>
        </clock>
      
      However we weren't testing any of those timer elements.
      039eb532
    • G
      build: fix linker error on FreeBSD · a90b9778
      Giuseppe Scrivano 提交于
      Commit 2d74822a renamed
      "freebsdNodeGetCPUCount" to "appleFreebsdNodeGetCPUCount", leaving one
      call to "freebsdNodeGetCPUCount".  Fix this other case.
      Signed-off-by: NGiuseppe Scrivano <gscrivan@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a90b9778
  5. 08 10月, 2013 2 次提交