1. 06 4月, 2011 2 次提交
  2. 05 4月, 2011 5 次提交
    • J
      qemu: Ignore unusable binaries · ef264e82
      Jiri Denemark 提交于
      When initializing qemu guest capabilities, we should ignore qemu
      binaries that we are not able to extract version/help info from since
      they will be unusable for creating domains anyway. Ignoring them is also
      much better than letting initialization of qemu driver fail.
      ef264e82
    • J
      qemu: Rewrite LOOKUP_PTYS macro into a function · 69afdf14
      Jiri Denemark 提交于
      The macro is huge and gives us nothing but headache when maintaining it.
      69afdf14
    • M
    • M
      qemu: Use heap allocated memory to read the monitor greeting · fb7f0051
      Matthias Bolte 提交于
      Removing a 4kb stack allocation.
      
      Reduce stack buffer for virStrerror to the common 1kb instead of 4kb.
      fb7f0051
    • E
      build: detect potentential uninitialized variables · 0d166c6b
      Eric Blake 提交于
      Even with -Wuninitialized (which is part of autobuild.sh
      --enable-compile-warnings=error), gcc does NOT catch this
      use of an uninitialized variable:
      
      {
        if (cond)
          goto error;
        int a = 1;
      error:
        printf("%d", a);
      }
      
      which prints 0 (supposing the stack started life wiped) if
      cond was true.  Clang will catch it, but we don't use clang
      as often.  Using gcc -Wjump-misses-init catches it, but also
      gives false positives:
      
      {
        if (cond)
          goto error;
        int a = 1;
        return a;
      error:
        return 0;
      }
      
      Here, a was never used in the scope of the error block, so
      declaring it after goto is technically fine (and clang agrees).
      However, given that our HACKING already documents a preference
      to C89 decl-before-statement, the false positive warning is
      enough of a prod to comply with HACKING.
      
      [Personally, I'd _really_ rather use C99 decl-after-statement
      to minimize scope, but until gcc can efficiently and reliably
      catch scoping and uninitialized usage bugs, I'll settle with
      the compromise of enforcing a coding standard that happens to
      reject false positives if it can also detect real bugs.]
      
      * acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
      * src/util/util.c (__virExec): Adjust offenders.
      * src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
      * src/remote/remote_driver.c (doRemoteOpen): Likewise.
      * src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
      (phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
      (phypGetStoragePoolDevice)
      (phypVolumeGetPhysicalVolumeByStoragePool)
      (phypVolumeGetPath): Likewise.
      * src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
      (vboxNetworkCreate, vboxNetworkDumpXML)
      (vboxNetworkDefineCreateXML): Likewise.
      * src/xenapi/xenapi_driver.c (getCapsObject)
      (xenapiDomainDumpXML): Likewise.
      * src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
      * src/security/security_selinux.c (SELinuxGenNewContext):
      Likewise.
      * src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
      Likewise.
      * src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
      Likewise.
      * src/qemu/qemu_driver.c (qemudDomainShutdown)
      (qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
      * src/storage/storage_backend_iscsi.c
      (virStorageBackendCreateIfaceIQN): Likewise.
      * src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
      0d166c6b
  3. 03 4月, 2011 2 次提交
  4. 01 4月, 2011 3 次提交
    • J
      qemu: Ignore libvirt debug messages in qemu log · 72ab0b6d
      Jiri Denemark 提交于
      qemu driver uses a 4K buffer for reading qemu log file. This is enough
      when only qemu's output is present in the log file. However, when
      debugging messages are turned on, intermediate libvirt process fills the
      log with a bunch of debugging messages before it executes qemu binary.
      In such a case the buffer may become too small. However, we are not
      really interested in libvirt messages so they can be filtered out from
      the buffer.
      72ab0b6d
    • O
      qemu: Fix improper logic of qemuCgroupSetup · 0ca16a78
      Osier Yang 提交于
      It throws errors as long as the cgroup controller is not available,
      regardless of whether we really want to use it to do setup or not,
      which is not what we want, fixing it with throwing error when need
      to use the controller.
      
      And change "VIR_WARN" to "qemuReportError" for memory controller
      incidentally.
      0ca16a78
    • W
      free tmp after unlinking it · e206946d
      Wen Congyang 提交于
      We create a temporary file to save memory, and we will remove it after reading
      memory to buffer. But we free the variable that contains the temporary filename
      before we remove it. So we should free tmp after unlinking it.
      e206946d
  5. 31 3月, 2011 2 次提交
    • E
      maint: avoid locale-sensitivity in string case comparisons · 6c9e89bb
      Eric Blake 提交于
      strcase{cmp/str} have the drawback of being sensitive to the global
      locale; this is unacceptable in a library setting.  Prefer a
      hard-coded C locale alternative for all but virsh, which is user
      facing and where the global locale isn't changing externally.
      
      * .gnulib: Update to latest, for c-strcasestr change.
      * bootstrap.conf (gnulib_modules): Drop strcasestr, add c-strcase
      and c-strcasestr.
      * cfg.mk (sc_avoid_strcase): New rule.
      (exclude_file_name_regexp--sc_avoid_strcase): New exception.
      * src/internal.h (STRCASEEQ, STRCASENEQ, STRCASEEQLEN)
      (STRCASENEQLEN): Adjust offenders.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextEjectMedia):
      Likewise.
      * tools/virsh.c (namesorter): Document exception.
      6c9e89bb
    • J
      qemu: Fix media eject with qemu-0.12.* · e586f574
      Jiri Denemark 提交于
      In qemu-0.12.* "device '...' is locked" message was changed to "Device
      ..." so libvirt was no longer detecting this as an error.
      e586f574
  6. 30 3月, 2011 4 次提交
    • W
      check whether qemuMonitorJSONHMP() failed · 0ecfa7f2
      Wen Congyang 提交于
      If qemu quited unexpectedly when we call qemuMonitorJSONHMP(),
      libvirt will crash.
      Steps to reproduce this bug:
      1. use gdb to attach libvirtd, and set a breakpoint in the function
         qemuMonitorSetCapabilities()
      2. start a vm
      3. let the libvirtd to run until qemuMonitorJSONSetCapabilities() returns.
      4. kill the qemu process
      5. continue running libvirtd
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      0ecfa7f2
    • W
      do not send monitor command after monitor meet error · cc2424fc
      Wen Congyang 提交于
      If the monitor met a error, and we will call qemuProcessHandleMonitorEOF().
      But we may try to send monitor command after qemuProcessHandleMonitorEOF()
      returned. Then libvirtd will be blocked in qemuMonitorSend().
      
      Steps to reproduce this bug:
      1. use gdb to attach libvirtd, and set a breakpoint in the function
         qemuConnectMonitor()
      2. start a vm
      3. let the libvirtd to run until qemuMonitorOpen() returns.
      4. kill the qemu process
      5. continue running libvirtd
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      cc2424fc
    • H
      qemu: unlock qemu driver before return from domain save · 025e1998
      Hu Tao 提交于
      qemuDriverUnlock() wasn't called on 2 exit paths
      * src/qemu/qemu_driver.c: fix qemudDomainSave() to always unlock
        the driver before exiting on error
      025e1998
    • N
      extend logging to record configuration-related changes · 343a27af
      Naoya Horiguchi 提交于
      Currently libvirt's default logging is limited and it is difficult to
      determine what was happening when a proglem occurred (especially on a
      machines where one don't know the detail.)  This patch helps to do that
      by making additional logging available for the following events:
      
        creating/defining/undefining domains
        creating/defining/undefining/starting/stopping networks
        creating/defining/undefining/starting/stopping storage pools
        creating/defining/undefining/starting/stopping storage volumes.
      
      * AUTHORS: add Naoya Horiguchi
      * src/network/bridge_driver.c src/qemu/qemu_driver.c
        src/storage/storage_driver.c: provide more VIR_INFO logging
      343a27af
  7. 29 3月, 2011 14 次提交
    • O
      cputune: Support cputune for qemu driver · 1cc4d025
      Osier Yang 提交于
      When domain startup, setting cpu affinity and cpu shares according
      to the cputune xml specified in domain xml.
      
      Modify "qemudDomainPinVcpu" to update domain config for vcpupin,
      and modify "qemuSetSchedulerParameters" to update domain config
      for cpu shares.
      
      v1 - v2:
         * Use "VIR_ALLOC_N" instead of "VIR_ALLOC_VAR"
         * But keep raising error when it fails on adding vcpupin xml
           entry, as I still don't have a better idea yet.
      1cc4d025
    • E
      qemu: fix regression with fd labeling on migration · daa6aa68
      Eric Blake 提交于
      My earlier testing for commit 34fa0de0 was done while starting
      just-built libvirt from an unconfined_t shell, where the fds happened
      to work when transferring to qemu.  But when installed and run under
      virtd_t, failure to label the raw file (with no compression) or the
      pipe (with compression) triggers SELinux failures when passing fds
      over SCM_RIGHTS to svirt_t qemu.
      
      * src/qemu/qemu_migration.c (qemuMigrationToFile): When passing
      FDs, make sure they are labeled.
      daa6aa68
    • E
      qemu: improve error message on failed fd transfer · 285e8a17
      Eric Blake 提交于
      First fallout of fd: migration - it looks like SELinux enforcing
      _does_ require fd labeling (running uninstalled libvirtd from an
      unconstrained shell had no problems, but once faked out by doing
       chcon `stat -c %C /usr/sbin/libvirtd` daemon/libvirtd
       run_init $PWD/daemon/libvirtd
      to run it with the same context as an init script service, and with
      SELinux enforcing, I got a rather confusing failure:
      error: Failed to save domain fedora_12 to fed12.img
      error: internal error unable to send TAP file handle: No file descriptor supplied via SCM_RIGHTS
      
      This fixes the error message, then I need to figure out a subsequent
      patch that does the fsetfilecon() necessary to keep things happy.
      It also appears that libvirtd hangs on a failed fd transfer; I don't
      know if that needs an independent fix.
      
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextSendFileHandle):
      Improve message, since TAP is no longer only client.
      285e8a17
    • D
      Enhance the streams helper to support plain file I/O · e886237a
      Daniel P. Berrange 提交于
      The O_NONBLOCK flag doesn't work as desired on plain files
      or block devices. Introduce an I/O helper program that does
      the blocking I/O operations, communicating over a pipe that
      can support O_NONBLOCK
      
      * src/fdstream.c, src/fdstream.h: Add non-blocking I/O
        on plain files/block devices
      * src/Makefile.am, src/util/iohelper.c: I/O helper program
      * src/qemu/qemu_driver.c, src/lxc/lxc_driver.c,
        src/uml/uml_driver.c, src/xen/xen_driver.c: Update for
        streams API change
      e886237a
    • E
      qemu: fix regression that hangs on save failure · 83b77fa5
      Eric Blake 提交于
      Regression introduced in commit 6034ddd5.
      
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Jump to correct
      label.
      83b77fa5
    • E
      qemu: support fd: migration with compression · 15d757ac
      Eric Blake 提交于
      Spawn the compressor ourselves, instead of requiring the shell.
      
      * src/qemu/qemu_migration.c (qemuMigrationToFile): Spawn
      compression helper process when needed.
      15d757ac
    • E
      qemu: skip granting access during fd migration · 34fa0de0
      Eric Blake 提交于
      SELinux labeling and cgroup ACLs aren't required if we hand a
      pre-opened fd to qemu.  All the more reason to love fd: migration.
      
      * src/qemu/qemu_migration.c (qemuMigrationToFile): Skip steps
      that are irrelevant in fd migration.
      34fa0de0
    • E
      qemu: consolidate migration to file code · 6034ddd5
      Eric Blake 提交于
      This points out that core dumps (still) don't work for root-squash
      NFS, since the fd is not opened correctly.  This patch should not
      introduce any functionality change, it is just a refactoring to
      avoid duplicated code.
      
      * src/qemu/qemu_migration.h (qemuMigrationToFile): New prototype.
      * src/qemu/qemu_migration.c (qemuMigrationToFile): New function.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag, doCoreDump): Use
      it.
      6034ddd5
    • E
      qemu: use common API for reading difficult files · 80449b32
      Eric Blake 提交于
      Direct access to an open file is so much simpler than passing
      everything through a pipe!
      
      * src/qemu/qemu_driver.c (qemudOpenAsUID)
      (qemudDomainSaveImageClose): Delete.
      (qemudDomainSaveImageOpen): Rename...
      (qemuDomainSaveImageOpen): ...and drop read_pid argument.  Use
      virFileOpenAs instead of qemudOpenAsUID.
      (qemudDomainSaveImageStartVM, qemudDomainRestore)
      (qemudDomainObjRestore): Rename...
      (qemuDomainSaveImageStartVM, qemuDomainRestore)
      (qemDomainObjRestore): ...and simplify accordingly.
      (qemudDomainObjStart, qemuDriver): Update callers.
      80449b32
    • E
      qemu, storage: improve type safety · 1a369dfb
      Eric Blake 提交于
      * src/storage/storage_backend.c (createRawFileOpHook): Change
      signature.
      (struct createRawFileOpHookData): Delete unused struct.
      (virStorageBackendCreateRaw): Adjust caller.
      * src/qemu/qemu_driver.c (struct fileOpHookData): Delete unused
      struct.
      (qemudDomainSaveFileOpHook): Rename...
      (qemuDomainSaveFileOpHook): ...and change signature.
      (qemudDomainSaveFlag): Adjust caller.
      1a369dfb
    • E
      util: rename virFileOperation to virFileOpenAs · 1fdd50f9
      Eric Blake 提交于
      This patch intentionally doesn't change indentation, in order to
      make it easier to review the real changes.
      
      * src/util/util.h (VIR_FILE_OP_RETURN_FD, virFileOperationHook):
      Delete.
      (virFileOperation): Rename...
      (virFileOpenAs): ...and reduce parameters.
      * src/util/util.c (virFileOperationNoFork, virFileOperation):
      Rename and simplify.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Adjust caller.
      * src/storage/storage_backend.c (virStorageBackendCreateRaw):
      Likewise.
      * src/libvirt_private.syms: Reflect rename.
      1fdd50f9
    • E
      qemu: simplify domain save fd handling · 3eede281
      Eric Blake 提交于
      This makes root-squash NFS saves more efficient.
      
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Use new
      virFileOperation flag to open fd only once.
      3eede281
    • E
      qemu: allow simple domain save to use fd: protocol · 9497506f
      Eric Blake 提交于
      This allows direct saves (no compression, no root-squash NFS) to use
      the more efficient fd: migration, which in turn avoids a race where
      qemu exec: migration can sometimes fail because qemu does a generic
      waitpid() that conflicts with the pclose() used by exec:.  Further
      patches will solve compression and root-squash NFS.
      
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Use new function
      when there is no compression.
      9497506f
    • E
      qemu: fix restoring a compressed save image · d51023d4
      Eric Blake 提交于
      Latent bug introduced in commit 2d6a5819 (Aug 2009), but not exposed
      until commit 1859939a (Jan 2011).  Basically, when virExec creates a
      pipe, it always marks libvirt's side as cloexec.  If libvirt then
      wants to hand that pipe to another child process, things work great if
      the fd is dup2()'d onto stdin or stdout (as with stdin: or exec:
      migration), but if the pipe is instead used as-is (such as with fd:
      migration) then qemu sees EBADF because the fd was closed at exec().
      
      This is a minimal fix for the problem at hand; it is slightly racy,
      but no more racy than the rest of libvirt fd handling, including the
      case of uncompressed save images.  A more invasive fix, but ultimately
      safer at avoiding leaking unintended fds, would be to _always and
      atomically_ open all fds as cloexec in libvirt (thanks to primitives
      like open(O_CLOEXEC), pipe2(), accept4(), ...), then teach virExec to
      clear that bit for all fds explicitly marked to be handed to the child
      only after forking.
      
      * src/qemu/qemu_command.c (qemuBuildCommandLine): Clear cloexec
      flag.
      * tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Tweak test.
      d51023d4
  8. 28 3月, 2011 2 次提交
    • E
      docs: document recent hook additions · ef701fd8
      Eric Blake 提交于
      * src/qemu/qemu_process.c (qemuProcessStart, qemuProcessStop): Fix
      typos.
      * docs/hooks.html.in: Document 'prepare' and 'release' hooks.
      ef701fd8
    • E
      qemu: don't restore state label twice · 96d56786
      Eric Blake 提交于
      Otherwise, if something like doStopVcpus fails after the first
      restore, a second restore is attempted and throws a useless
      warning.
      
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Avoid second
      restore of state label.
      96d56786
  9. 25 3月, 2011 4 次提交
    • P
      Add missing { for qemudDomainInterfaceStats · 24da1095
      Philipp Hahn 提交于
      Add missing open curly brace between function declaration of non-linux
      variant of qemudDomainInterfaceStats() and its body.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      24da1095
    • W
      fix the check of the output of monitor command 'device_add' · c4dae2d9
      Wen Congyang 提交于
      Hotpluging host usb device by text mode will fail, because the monitor
      command 'device_add' outputs 'husb: using...' if it succeeds, but we
      think the command should not output anything.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      c4dae2d9
    • E
      build: enforce reference count checking · 72d4ff5b
      Eric Blake 提交于
      Add the compiler attribute to ensure we don't introduce any more
      ref bugs like were just patched in commit 9741f346, then explicitly
      mark the remaining places in code that are safe.
      
      * src/qemu/qemu_monitor.h (qemuMonitorUnref): Mark
      ATTRIBUTE_RETURN_CHECK.
      * src/conf/domain_conf.h (virDomainObjUnref): Likewise.
      * src/conf/domain_conf.c (virDomainObjParseXML)
      (virDomainLoadStatus): Fix offenders.
      * src/openvz/openvz_conf.c (openvzLoadDomains): Likewise.
      * src/vmware/vmware_conf.c (vmwareLoadDomains): Likewise.
      * src/qemu/qemu_domain.c (qemuDomainObjBeginJob)
      (qemuDomainObjBeginJobWithDriver)
      (qemuDomainObjExitRemoteWithDriver): Likewise.
      * src/qemu/qemu_monitor.c (QEMU_MONITOR_CALLBACK): Likewise.
      Suggested by Daniel P. Berrange.
      72d4ff5b
    • E
      maint: prohibit access(,X_OK) · 391c397e
      Eric Blake 提交于
      This simplifies several callers that were repeating checks already
      guaranteed by util.c, and makes other callers more robust to now
      reject directories.  remote_driver.c was over-strict - access(,R_OK)
      is only needed to execute a script file; a binary only needs
      access(,X_OK) (besides, it's unusual to see a file with x but not
      r permissions, whether script or binary).
      
      * cfg.mk (sc_prohibit_access_xok): New syntax-check rule.
      (exclude_file_name_regexp--sc_prohibit_access_xok): Exempt one use.
      * src/network/bridge_driver.c (networkStartRadvd): Fix offenders.
      * src/qemu/qemu_capabilities.c (qemuCapsProbeMachineTypes)
      (qemuCapsInitGuest, qemuCapsInit, qemuCapsExtractVersionInfo):
      Likewise.
      * src/remote/remote_driver.c (remoteFindDaemonPath): Likewise.
      * src/uml/uml_driver.c (umlStartVMDaemon): Likewise.
      * src/util/hooks.c (virHookCheck): Likewise.
      391c397e
  10. 24 3月, 2011 1 次提交
    • W
      update domain status forcibly even if attach a device failed · 9450a7cb
      Wen Congyang 提交于
      Steps to reproduce this bug:
      1. virsh attach-disk domain --source diskimage --target sdb --sourcetype file --driver qemu --subdriver qcow2
         error: Failed to attach disk
         error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'
      2. service libvirtd restart
         Stopping libvirtd daemon:                                  [  OK  ]
         Starting libvirtd daemon:                                  [  OK  ]
      3. virsh attach-disk domain --source diskimage --target sdb --sourcetype file --driver qemu --subdriver raw
         error: Failed to attach disk
         error: operation failed: adding lsi,id=scsi0,bus=pci.0,addr=0x6 device failed: Duplicate ID 'scsi0' for device
      
      The reason is that we create a new scsi controller but we do not update
      /var/run/libvirt/qemu/domain.xml.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      9450a7cb
  11. 23 3月, 2011 1 次提交