1. 04 2月, 2011 5 次提交
    • J
      qemu: Support booting from hostdev PCI devices · 963a9460
      Jiri Denemark 提交于
      963a9460
    • J
      Support booting from hostdev devices · 83e335f9
      Jiri Denemark 提交于
      83e335f9
    • J
      qemu: Add shortcut for HMP pass through · 2169472a
      Jiri Denemark 提交于
      Currently users who want to use virDomainQemuMonitorCommand() API or
      it's virsh equivalent has to use the same protocol as libvirt uses for
      communication to qemu. Since the protocol is QMP with current qemu and
      HMP much more usable for humans, one ends up typing something like the
      following:
      
          virsh qemu-monitor-command DOM \
      '{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'
      
      which is not a very convenient way of debugging qemu.
      
      This patch introduces --hmp option to qemu-monitor-command, which says
      that the provided command is in HMP. If libvirt uses QMP to talk with
      qemu, the command will automatically be converted into QMP. So the
      example above is simplified to just
      
          virsh qemu-monitor-command --hmp DOM "info kvm"
      
      Also the result is converted from
      
          {"return":"kvm support: enabled\r\n"}
      
      to just plain HMP:
      
          kvm support: enabled
      
      If libvirt talks to qemu in HMP, --hmp flag is obviously a noop.
      2169472a
    • S
      macvtap: fix 2 nla_put expressions (non-serious bug) · be23e2bd
      Stefan Berger 提交于
      This patch fixes 2 occurrences of nla_put expression with a '!' in
      front of them that basically prevented the detection that the buffer
      is too small. However, code further below would then detect that the
      buffer is too small when further parts are added to the netlink message.
      be23e2bd
    • E
      qemu: avoid double shutdown · 9962e406
      Eric Blake 提交于
      * src/qemu/qemu_driver.c (qemudShutdownVMDaemon): Check that vm is
      still active.
      Reported by Wen Congyang as follows:
      
      Steps to reproduce this bug:
      
      1. use gdb to debug libvirtd, and set breakpoint in the function
         qemuConnectMonitor()
      2. start a vm, and the libvirtd will be stopped in qemuConnectMonitor()
      3. kill -STOP $(cat /var/run/libvirt/qemu/<domain>.pid)
      4. continue to run libvirtd in gdb, and libvirtd will be blocked in the
         function qemuMonitorSetCapabilities()
      5. kill -9 $(cat /var/run/libvirt/qemu/<domain>.pid)
      
      Here is log of the qemu:
      =========
      LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin ...
      char device redirected to /dev/pts/3
      2011-01-27 09:38:48.101: shutting down
      2011-01-27 09:41:26.401: shutting down
      =========
      
      The vm is shut down twice. I do not know whether this behavior has
      side effect, but I think we should shutdown the vm only once.
      9962e406
  2. 03 2月, 2011 4 次提交
  3. 02 2月, 2011 2 次提交
    • D
      Don't sleep in poll() if there is existing SASL decoded data · 68d2c348
      Daniel P. Berrange 提交于
      In the SASL codepath we typically read far more data off the
      wire than we immediately need. When using a connection from a
      single thread this isn't a problem, since only our reply will
      be pending (or an event we can handle directly). When using a
      connection from multiple threads though, we may read the data
      from replies from other threads. If those replies occur after
      our own reply, they'll not be processed. The other thread will
      then go into poll() and wait for its reply which has already
      been received and decoded. The solution is to set poll() timeout
      to 0 if there is pending SASL data.
      
      * src/remote/remote_driver.c: Don't sleep in poll() if SASL
        data exists
      68d2c348
    • S
      macvtap: fix variable in debugging output · c31e6cdc
      Stefan Berger 提交于
      This patch fixes a variable in the debugging output.
      c31e6cdc
  4. 01 2月, 2011 2 次提交
  5. 31 1月, 2011 2 次提交
  6. 30 1月, 2011 2 次提交
    • E
      maint: reject raw close, popen in 'make syntax-check' · 030ce43b
      Eric Blake 提交于
      commit f1fe9671 was supposed to make sure we use files.h
      macros to avoid double close, but it didn't work.
      
      Meanwhile, virCommand is vastly superior to system(), fork(),
      and popen() (also to virExec, but we haven't completed that
      conversion), so enforce that, too.
      
      * cfg.mk (sc_prohibit_close): Fix typo that excluded close, and
      add pclose.
      (sc_prohibit_fork_wrappers): New rule, for fork, system, and popen.
      * .x-sc_prohibit_close: More exemptions.
      * .x-sc_prohibit_fork_wrappers: New file.
      * Makefile.am (syntax_check_exceptions): Ship new file.
      * src/datatypes.c (virReleaseConnect): Tweak comment to avoid
      false positive.
      * src/util/files.h (VIR_CLOSE): Likewise.
      030ce43b
    • E
      build: avoid close, system · e67ae619
      Eric Blake 提交于
      * src/fdstream.c (virFDStreamOpenFile, virFDStreamCreateFile):
      Use VIR_FORCE_CLOSE instead of close.
      * tests/commandtest.c (mymain): Likewise.
      * tools/virsh.c (editFile): Use virCommand instead of system.
      * src/util/util.c (__virExec): Special case preservation of std
      file descriptors to child.
      e67ae619
  7. 29 1月, 2011 8 次提交
  8. 28 1月, 2011 6 次提交
    • D
      Remove bogus log warning lines when launching QEMU · 0095edaa
      Daniel P. Berrange 提交于
      The refactoring of QEMU command startup was comitted with
      a couple of VIR_WARN lines left in from debugging.
      
      * src/qemu/qemu_driver.c: Remove log warning lines
      0095edaa
    • D
      Remove double close of qemu monitor · e85247e7
      Daniel P. Berrange 提交于
      When qemuMonitorSetCapabilities() fails, there is no need to
      call qemuMonitorClose(), because the caller will already see
      the error code and tear down the entire VM. The extra call to
      qemuMonitorClose resulted in a double-free due to it removing
      a ref count prematurely.
      
      * src/qemu/qemu_driver.c: Remove premature close of monitor
      e85247e7
    • E
      qemu: fix error messages · b96b6f47
      Eric Blake 提交于
      Regression in commit caa805ea let a lot of bad messages slip in.
      
      * cfg.mk (msg_gen_function): Fix function name.
      * src/qemu/qemu_cgroup.c (qemuRemoveCgroup): Fix fallout from
      'make syntax-check'.
      * src/qemu/qemu_driver.c (qemudDomainGetInfo)
      (qemuDomainWaitForMigrationComplete, qemudStartVMDaemon)
      (qemudDomainSaveFlag, qemudDomainAttachDevice)
      (qemuDomainUpdateDeviceFlags): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachHostUsbDevice)
      (qemuDomainDetachPciDiskDevice, qemuDomainDetachSCSIDiskDevice):
      Likewise.
      b96b6f47
    • H
      qemu: Report more accurate error on failure to attach device. · cdbba1c4
      Hu Tao 提交于
      When attaching device from a xml file and the device is mis-configured,
      virsh gives mis-leading message "out of memory". This patch fixes this.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cdbba1c4
    • E
      qemu: use separate alias for chardev and associated device · 3fdc7895
      Eric Blake 提交于
      * src/qemu/qemu_command.c (qemuBuildChrChardevStr): Alter the
      chardev alias.
      (qemuBuildCommandLine): Output an id for the chardev counterpart.
      * tests/qemuxml2argvdata/*: Update tests to match.
      Reported by Daniel P. Berrange.
      3fdc7895
    • W
      avoid vm to be deleted if qemuConnectMonitor failed · d96431f9
      Wen Congyang 提交于
      Steps to reproduce this bug:
      1. service libvirtd start
      2. virsh start <domain>
      3. kill -STOP $(cat /var/run/libvirt/qemu/<domain>.pid)
      4. service libvirtd restart
      5. kill -9 $(cat /var/run/libvirt/qemu/<domain>.pid)
      
      Then libvirtd will core dump or be in deadlock state.
      
      Make sure that json is built into libvirt and the version
      of qemu is newer than 0.13.0.
      
      The reason of libvirtd cores dump is that:
      We add vm->refs when we alloc the memory, and decrease it
      in the function qemuHandleMonitorEOF() in other thread.
      
      We add vm->refs in the function qemuConnectMonitor() and
      decrease it when the vm is inactive.
      
      The libvirtd will block in the function qemuMonitorSetCapabilities()
      because the vm is stopped by signal SIGSTOP. Now the vm->refs is 2.
      
      Then we kill the vm by signal SIGKILL. The function
      qemuMonitorSetCapabilities() failed, and then we will decrease vm->refs
      in the function qemuMonitorClose().
      In another thread, mon->fd is broken and the function
      qemuHandleMonitorEOF() is called.
      
      If qemuHandleMonitorEOF() decreases vm->refs before qemuConnectMonitor()
      returns, vm->refs will be decrease to 0 and the memory is freed.
      
      We will call qemudShutdownVMDaemon() as qemuConnectMonitor() failed.
      The memory has been freed, so qemudShutdownVMDaemon() is too dangerous.
      
      We will reference NULL pointer in the function virDomainConfVMNWFilterTeardown():
      =============
      void
      virDomainConfVMNWFilterTeardown(virDomainObjPtr vm) {
          int i;
      
          if (nwfilterDriver != NULL) {
              for (i = 0; i < vm->def->nnets; i++)
                  virDomainConfNWFilterTeardown(vm->def->nets[i]);
          }
      }
      ============
      vm->def->nnets is not 0 but vm->def->nets is NULL(We don't set vm->def->nnets
      to 0 when we free vm).
      
      We should add an extra reference of vm to avoid vm to be deleted if
      qemuConnectMonitor() failed.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      d96431f9
  9. 27 1月, 2011 3 次提交
    • O
      remote: Add extra parameter pkipath for URI · 31242565
      Osier Yang 提交于
      This new parameter allows user specifies where the client
      cerficate, client key, CA certificate of x509 is, instead of
      hardcoding it. If 'pkipath' is not specified, and the user
      is not root, try to find files in $HOME/.pki/libvirt, as long
      as one of client cerficate, client key, CA certificate can
      not be found, use default global location (LIBVIRT_CACERT,
      LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
      src/remote/remote_driver.h)
      
      Example of use:
      
      [root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
      error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
      or directory
      error: failed to connect to the hypervisor
      [root@Osier client]# ls -l
      total 24
      -rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
      -rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
      -rw-r--r--. 1 root root  132 Jan 23 19:04 client.info
      -rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
      
      [root@Osier client]# cp /tmp/cacert.pem .
      [root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
      Welcome to virsh, the virtualization interactive terminal.
      
      Type:  'help' for help with commands
      'quit' to quit
      
      virsh #
      
      * src/remote/remote_driver.c: adds support for the new pkipath URI parameter
      31242565
    • O
      storage: Round up capacity for LVM volume creation · 6002e040
      Osier Yang 提交于
      If vol->capacity is odd, the capacity will be rounded down
      by devision, this patch is to round it up instead of rounding
      down, to be safer in case of one writes to the volume with the
      size he used to create.
      
      - src/storage/storage_backend_logical.c: make sure size is not rounded down
      6002e040
    • D
      Do not use virtio-serial port 0 for generic ports · 8e28c5d4
      David Allan 提交于
      Per the discussion in:
      
      https://bugzilla.redhat.com/show_bug.cgi?id=670394
      
      The port numbering should start from 1, not 0.  We assign maxport + 1,
      so start maxport at 0.
      8e28c5d4
  10. 26 1月, 2011 6 次提交
    • L
      Manually kill gzip if restore fails before starting qemu · c9c794b5
      Laine Stump 提交于
      If a guest image is saved in compressed format, and the restore fails
      in some way after the intermediate process used to uncompress the
      image has been started, but before qemu has been started to hook up to
      the uncompressor, libvirt will endlessly wait for the uncompressor to
      finish, but it never will because it's still waiting to have something
      hooked up to drain its output.
      
      The solution is to close the pipes on both sides of the uncompressor,
      then send a SIGTERM before calling waitpid on it (only if the restore
      has failed, of course).
      c9c794b5
    • D
      Add check for poll error events in monitor · e0e4e4de
      Daniel P. Berrange 提交于
      Handle poll errors in the same way as hangup event
      
      * src/qemu/qemu_monitor.c: Handle error events
      e0e4e4de
    • D
      Filter out certain expected error messages from libvirtd · b8786c06
      Daniel P. Berrange 提交于
      Add a hook to the error reporting APIs to allow specific
      error messages to be filtered out. Wire up libvirtd to
      remove VIR_ERR_NO_DOMAIN & similar error codes from the
      logs. They are still logged at DEBUG level.
      
      * daemon/libvirtd.c: Filter VIR_ERR_NO_DOMAIN and friends
      * src/libvirt_private.syms, src/util/virterror.c,
        src/util/virterror_internal.h: Hook for changing error
        reporting level
      b8786c06
    • D
      Revert all previous error log priority hacks · dbfca3ff
      Daniel P. Berrange 提交于
      This reverts the additions in commit
      
        abff683f
      
      taking us back to state where all errors are fully logged
      in both libvirtd and normal clients.
      
      THe intent was to stop VIR_ERR_NO_DOMAIN (No such domain
      with UUID XXXX) messages from client apps polluting syslog
      The change affected all error codes, but more seriously,
      it also impacted errors from internal libvirtd infrastructure
      For example guest autostart no longer logged errors. The
      libvirtd network code no longer logged some errors. This
      makes debugging incredibly hard
      
      * daemon/libvirtd.c: Remove error log priority filter
      * src/util/virterror.c, src/util/virterror_internal.h: Remove
        callback for overriding log priority
      dbfca3ff
    • D
      Cleanup code style in logging APIs · 2b7ac883
      Daniel P. Berrange 提交于
      Remove use of brackets around following return statement.
      Fix indentation of two switch statements
      2b7ac883
    • L
      Set SELinux context label of pipes used for qemu migration · 34a19dda
      Laine Stump 提交于
      This patch is a partial resolution to the following bug:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=667756
      
      (to complete the fix, an updated selinux-policy package is required,
      to add the policy that allows libvirt to set the context of a fifo,
      which was previously not allowed).
      
      Explanation : When an incoming migration is over a pipe (for example,
      if the image was compressed and is being fed through gzip, or was on a
      root-squash nfs server, so needed to be opened by a child process
      running as a different uid), qemu cannot read it unless the selinux
      context label for the pipe has been set properly.
      
      The solution is to check the fd used as the source of the migration
      just before passing it to qemu; if it's a fifo (implying that it's a
      pipe), we call the newly added virSecurityManagerSetFDLabel() function
      to set the context properly.
      34a19dda