1. 26 11月, 2015 1 次提交
    • E
      qga: Better mapping of SEEK_* in guest-file-seek · 0a982b1b
      Eric Blake 提交于
      Exposing OS-specific SEEK_ constants in our qapi was a mistake
      (if the host has SEEK_CUR as 1, but the guest has it as 2, then
      the semantics are unclear what should happen); if we had a time
      machine, we would instead expose only a symbolic enum.  It's too
      late to change the fact that we have an integer in qapi, but we
      can at least document what mapping we want to enforce for all
      qga clients (and luckily, it happens to be the mapping that both
      Linux and Windows use); then fix the code to match that mapping.
      It also helps us filter out unsupported SEEK_DATA and SEEK_HOLE.
      
      In the future, we may wish to move our QGA_SEEK_* constants into
      qga/qapi-schema.json, along with updating the schema to take an
      alternate type (either the integer, or the string value of the
      enum name) - but that's too much risk during hard freeze.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      0a982b1b
  2. 20 10月, 2015 2 次提交
    • Y
      qga: guest-exec simple stdin/stdout/stderr redirection · a1853dca
      Yuri Pudgorodskiy 提交于
      Implemented with base64-encoded strings in qga json protocol.
      Glib portable GIOChannel is used for data I/O.
      
      Optinal stdin parameter of guest-exec command is now used as
      stdin content for spawned subprocess.
      
      If capture-output bool flag is specified, guest-exec redirects out/err
      file descriptiors internally to pipes and collects subprocess
      output.
      
      Guest-exe-status is modified to return this collected data to requestor
      in base64 encoding.
      Signed-off-by: NYuri Pudgorodskiy <yur@virtuozzo.com>
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      * switch from 'struct GuestIOExecData' to 'GuestIOExecData'
      * s/TRUE/true/g, s/FALSE/false/g for gboolean return values
      * s/inp_data/input_data/
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      a1853dca
    • Y
      qga: guest exec functionality · d697e30c
      Yuri Pudgorodskiy 提交于
      Guest-exec rewritten in platform-independent style with glib spawn.
      
      Child process is spawn asynchronously and exit status can later
      be picked up by guest-exec-status command.
      
      stdin/stdout/stderr of the child now is redirected to /dev/null
      Later we will add ability to specify stdin in guest-exec command
      and to get collected stdout/stderr with guest-exec-status.
      Signed-off-by: NYuri Pudgorodskiy <yur@virtuozzo.com>
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      CC: Michael Roth <mdroth@linux.vnet.ibm.com>
      * use g_new0 in place of g_malloc for GuestExec struct
      * commit msg spelling fixes
      * s/inp-data/input-data
      * document capture-input mode as false by default
      * use GetProcessId() for pids on w32 instead of casting HANDLE
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      d697e30c
  3. 11 9月, 2015 1 次提交
  4. 02 9月, 2015 1 次提交
  5. 22 7月, 2015 1 次提交
  6. 08 7月, 2015 2 次提交
    • O
      qga: added bus type and disk location path · a3ef3b22
      Olga Krishtal 提交于
      According to Microsoft disk location path can be obtained via
      IOCTL_SCSI_GET_ADDRESS. Unfortunately this ioctl can not be used for all
      devices. There are certain bus types which could be obtained with this
      API. Please, refer to the following link for more details
      https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx
      
      Bus type could be obtained using IOCTL_STORAGE_QUERY_PROPERTY. Enum
      STORAGE_BUS_TYPE describes all buses supported by OS.
      
      Windows defines more bus types than Linux. Thus some values have been added
      to GuestDiskBusType.
      Signed-off-by: NOlga Krishtal <okrishtal@virtuozzo.com>
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      CC: Eric Blake <eblake@redhat.com>
      CC: Michael Roth <mdroth@linux.vnet.ibm.com>
      * fixed warning in CreateFile due to use of NULL instead of 0
      * only provide disk info when CONFIG_QGA_NTDDSCSI=y
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      a3ef3b22
    • J
      qga/qmp_guest_fstrim: Return per path fstrim result · e82855d9
      Justin Ossevoort 提交于
      The current guest-fstrim support only returns an error if some
      mountpoint was unable to be trimmed, skipping any possible additional
      mountpoints. The result of the TRIM operation itself is also discarded.
      
      This change returns a per mountpoint result of the TRIM operation. If an
      error occurs on some mountpoints that error is returned and the
      guest-fstrim continue with any additional mountpoints.
      
      The returned values for errors, minimum and trimmed are dependant on the
      filesystem, storage stacks and kernel version.
      Signed-off-by: NJustin Ossevoort <justin@quarantainenet.nl>
      * s/type/struct/ in schema type definitions
      * moved version annotation for new guest-fstrim return field to
        the field itself rather than applying to the entire command
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      e82855d9
  7. 06 5月, 2015 2 次提交
    • E
      qapi: Use 'struct' instead of 'type' in schema · 895a2a80
      Eric Blake 提交于
      Referring to "type" as both a meta-type (built-in, enum, union,
      alternate, or struct) and a specific type (the name that the
      schema uses for declaring structs) is confusing.  Do the bulk of
      the conversion to "struct" in qapi schema, with a fairly
      mechanical:
      
      for f in `find -name '*.json'; do sed -i "s/'type'/'struct'/"; done
      
      followed by manually filtering out the places where we have a
      'type' embedded in 'data'.  Then tweak a couple of tests whose
      output changes slightly due to longer lines.
      
      I also verified that the generated files for QMP and QGA (such
      as qmp-commands.h) are the same before and after, as assurance
      that I didn't leave in any accidental member name changes.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      895a2a80
    • E
      qapi: Unify type bypass and add tests · d708cdbe
      Eric Blake 提交于
      For a few QMP commands, we are forced to pass an arbitrary type
      without tracking it properly in QAPI.  Among the existing clients,
      this unnamed type was spelled 'dict', 'visitor', and '**'; this
      patch standardizes on '**', matching the documentation changes
      earlier in the series.
      
      Meanwhile, for the 'gen' key, we have been ignoring the value,
      although the schema consistently used "'no'" ('success-response'
      was hard-coded to checking for 'no').  But now that we can support
      a literal "false" in the schema, we might as well use that rather
      than ignoring the value or special-casing a random string.  Note
      that these are one-way switches (use of 'gen':true is not the same
      as omitting 'gen'). Also, the use of '**' requires 'gen':false,
      but the use of 'gen':false does not mandate the use of '**'.
      
      There is no difference to the generated code.  Add some tests on
      what we'd like to guarantee, although it will take later patches
      to clean up test results and actually enforce the use of a bool
      parameter.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d708cdbe
  8. 30 4月, 2015 1 次提交
  9. 18 2月, 2015 2 次提交
  10. 17 2月, 2015 1 次提交
    • D
      qga: add guest-set-user-password command · 215a2771
      Daniel P. Berrange 提交于
      Add a new 'guest-set-user-password' command for changing the password
      of guest OS user accounts. This command is needed to enable OpenStack
      to support its API for changing the admin password of guests running
      on KVM/QEMU. It is not practical to provide a command at the QEMU
      level explicitly targetting administrator account password change
      only, since different guest OS have different names for the admin
      account. While UNIX systems use 'root', Windows systems typically
      use 'Administrator' and even that can be renamed. Higher level apps
      like OpenStack have the ability to figure out the correct admin
      account name since they have info that QEMU/libvirt do not.
      
      The command accepts either the clear text password string, encoded
      in base64 to make it 8-bit safe in JSON:
      
      $ echo -n "123456" | base64
      MTIzNDU2
      $ virsh -c qemu:///system  qemu-agent-command f21x86_64 \
         '{ "execute": "guest-set-user-password",
            "arguments": { "crypted": false,
                           "username": "root",
                           "password": "MTIzNDU2" } }'
        {"return":{}}
      
      Or a password that has already been run though a crypt(3) like
      algorithm appropriate for the guest, again then base64 encoded:
      
      $ echo -n '$6$n01A2Tau$e...snip...DfMOP7of9AJ1I8q0' | base64
      JDYkb...snip...YT2Ey
      $ virsh -c qemu:///system  qemu-agent-command f21x86_64 \
         '{ "execute": "guest-set-user-password",
            "arguments": { "crypted": true,
                           "username": "root",
                           "password": "JDYkb...snip...YT2Ey" } }'
      
      NB windows support is desirable, but not implemented in this
      patch.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      215a2771
  11. 08 8月, 2014 2 次提交
    • T
      qga: Add guest-get-fsinfo command · 46d4c572
      Tomoki Sekiyama 提交于
      Add command to get mounted filesystems information in the guest.
      The returned value contains a list of mountpoint paths and
      corresponding disks info such as disk bus type, drive address,
      and the disk controllers' PCI addresses, so that management layer
      such as libvirt can resolve the disk backends.
      
      For example, when `lsblk' result is:
      
          NAME           MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
          sdb              8:16   0    1G  0 disk
          `-sdb1           8:17   0 1024M  0 part
            `-vg0-lv0    253:1    0  1.4G  0 lvm  /mnt/test
          sdc              8:32   0    1G  0 disk
          `-sdc1           8:33   0  512M  0 part
            `-vg0-lv0    253:1    0  1.4G  0 lvm  /mnt/test
          vda            252:0    0   25G  0 disk
          `-vda1         252:1    0   25G  0 part /
      
      where sdb is a SCSI disk with PCI controller 0000:00:0a.0 and ID=1,
            sdc is an IDE disk with PCI controller 0000:00:01.1, and
            vda is a virtio-blk disk with PCI device 0000:00:06.0,
      
      guest-get-fsinfo command will return the following result:
      
          {"return":
           [{"name":"dm-1",
             "mountpoint":"/mnt/test",
             "disk":[
              {"bus-type":"scsi","bus":0,"unit":1,"target":0,
               "pci-controller":{"bus":0,"slot":10,"domain":0,"function":0}},
              {"bus-type":"ide","bus":0,"unit":0,"target":0,
               "pci-controller":{"bus":0,"slot":1,"domain":0,"function":1}}],
             "type":"xfs"},
            {"name":"vda1", "mountpoint":"/",
             "disk":[
              {"bus-type":"virtio","bus":0,"unit":0,"target":0,
               "pci-controller":{"bus":0,"slot":6,"domain":0,"function":0}}],
             "type":"ext4"}]}
      
      In Linux guest, the disk information is resolved from sysfs. So far,
      it only supports virtio-blk, virtio-scsi, IDE, SATA, SCSI disks on x86
      hosts, and "disk" parameter may be empty for unsupported disk types.
      Signed-off-by: NTomoki Sekiyama <tomoki.sekiyama@hds.com>
      
      *updated schema to report 2.2 as initial supported version
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      46d4c572
    • T
      qga: Add guest-fsfreeze-freeze-list command · e99bce20
      Tomoki Sekiyama 提交于
      If an array of mount point paths is specified as 'mountpoints' argument
      of guest-fsfreeze-freeze-list, qemu-ga will only freeze the file systems
      mounted on specified paths in Linux guests. Otherwise, it works as the
      same way as guest-fsfreeze-freeze.
      This would be useful when the host wants to create partial disk snapshots.
      Signed-off-by: NTomoki Sekiyama <tomoki.sekiyama@hds.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      
      *updated schema to report 2.2 as initial supported version
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      e99bce20
  12. 18 4月, 2014 1 次提交
  13. 24 2月, 2014 1 次提交
  14. 11 10月, 2013 1 次提交
  15. 02 4月, 2013 2 次提交
  16. 12 3月, 2013 3 次提交
  17. 15 1月, 2013 1 次提交
  18. 19 12月, 2012 1 次提交
  19. 14 9月, 2012 1 次提交
  20. 22 6月, 2012 1 次提交
    • P
      qemu-ga: add guest-fstrim command · eab5fd59
      Paolo Bonzini 提交于
      FITRIM is a mounted filesystem feature to discard (or "trim") blocks which
      are not in use by the filesystem. This is useful for solid-state drives
      (SSDs) and thinly-provisioned storage.  Provide access to the feature
      from the host so that filesystems can be trimmed periodically or before
      migration.
      
      Here is an example using scsi_debug:
      
          # modprobe scsi_debug lbpu=1 lbpws=1
          # sg_vpd -p0xb2 /dev/sdb
          Logical block provisioning VPD page (SBC):
            Unmap command supported (LBPU): 1
            Write same (16) with unmap bit supported (LBWS): 1
            Write same (10) with unmap bit supported (LBWS10): 0
          # mke2fs /dev/sdb
          # cat /sys/bus/pseudo/drivers/scsi_debug/map
          1-616,16257-16383
          # mount /dev/sdb /run/media/pbonzini/test
          # dd if=/dev/zero of=/run/media/pbonzini/test/file
          # cat map
          1-616,645-1588,1599-4026,4029-16383
          # rm /run/media/pbonzini/test/file
          # ./qemu-ga /dev/fd/0
          {"execute":"guest-fstrim"}
          {"return": {}}
          # cat map
          1-612
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NLuiz Capitulino <lcapitulino@redhat.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      eab5fd59
  21. 15 5月, 2012 5 次提交
  22. 14 5月, 2012 1 次提交
    • J
      fix some common typos · a31f0531
      Jim Meyering 提交于
      These were identified using: http://github.com/lyda/misspell-check
      and run like this to create a bourne shell script using GNU sed's
      -i option:
      
      git ls-files|grep -vF .bin | misspellings -f - |grep -v '^ERROR:' |perl \
      -pe 's/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/sed -i '\''${2}s!$3!$4!'\'' $1/'
      
      Manually eliding the FP, "rela->real" and resolving "addres" to
      address (not "adders") we get this:
      
        sed -i '450s!thru!through!' Changelog
        sed -i '260s!neccessary!necessary!' coroutine-sigaltstack.c
        sed -i '54s!miniscule!minuscule!' disas.c
        sed -i '1094s!thru!through!' hw/usb/hcd-ehci.c
        sed -i '1095s!thru!through!' hw/usb/hcd-ehci.c
        sed -i '21s!unecessary!unnecessary!' qapi-schema-guest.json
        sed -i '307s!explictly!explicitly!' qemu-ga.c
        sed -i '490s!preceeding!preceding!' qga/commands-posix.c
        sed -i '792s!addres!address!' qga/commands-posix.c
        sed -i '6s!beeing!being!' tests/tcg/test-mmap.c
      
      Also, manually fix "arithmentic", spotted by Peter Maydell:
      
        sed -i 's!arithmentic!arithmetic!' coroutine-sigaltstack.c
      Signed-off-by: NJim Meyering <meyering@redhat.com>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      a31f0531
  23. 30 4月, 2012 2 次提交
    • M
      qemu-ga: persist tracking of fsfreeze state via filesystem · f789aa7b
      Michael Roth 提交于
      Currently, qemu-ga may die/get killed/go away for whatever reason after
      guest-fsfreeze-freeze has been issued, and before guest-fsfreeze-thaw
      has been issued. This means the only way to unfreeze the guest is via
      VNC/network/console access, but obtaining that access after-the-fact can
      often be very difficult when filesystems are frozen. Logins will almost
      always hang, for instance. In many cases the only recourse would be to
      reboot the guest without any quiescing of volatile state, which makes
      this a corner-case worth giving some attention to.
      
      A likely failsafe for this situation would be to use a watchdog to
      restart qemu-ga if it goes away. There are some precautions qemu-ga
      needs to take in order to avoid immediately hanging itself on I/O,
      however, namely, we must disable logging and defer to processing/creation
      of user-specific logfiles, along with creation of the pid file if we're
      running as a daemon. We also need to disable non-fsfreeze-safe commands,
      as we normally would when processing the guest-fsfreeze-freeze command.
      
      To track when we need to do this in a way that persists between multiple
      invocations of qemu-ga, we create a file on the guest filesystem before
      issuing the fsfreeze, and delete it when doing the thaw. On qemu-ga
      startup, we check for the existance of this file to determine
      the need to take the above precautions.
      
      We're forced to do it this way since a more traditional approach such as
      reading/writing state to a dedicated state file will cause
      access/modification time updates, respectively, both of which will hang
      if the file resides on a frozen filesystem. Both can occur even if
      relatime is enabled. Checking for file existence will not update the
      access time, however, so it's a safe way to check for fsfreeze state.
      
      An actual watchdog-based restart of qemu-ga can itself cause an access
      time update that would thus hang the invocation of qemu-ga, but the
      logic to workaround that can be handled via the watchdog, so we don't
      address that here (for relatime we'd periodically touch the qemu-ga
      binary if the file $qga_statedir/qga.state.isfrozen is not present, this
      avoids qemu-ga updates or the 1 day relatime threshold causing an
      access-time update if we try to respawn qemu-ga shortly after it goes
      away)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      f789aa7b
    • M
      qemu-ga: improve recovery options for fsfreeze · 9e8aded4
      Michael Roth 提交于
      guest-fsfreeze-thaw relies on state information obtained from
      guest-fsfreeze-freeze to determine what filesystems to unfreeze.
      This is unreliable due to the fact that that state does not account
      for FIFREEZE being issued by other processes, or previous instances
      of qemu-ga. This means in certain situations we cannot thaw
      filesystems even with a responsive qemu-ga instance at our disposal.
      
      This patch allows guest-fsfreeze-thaw to be issued unconditionally.
      It also adds some additional logic to allow us to thaw filesystems
      regardless of how many times the filesystem's "frozen" refcount has
      been incremented by any guest processes.
      
      Also, guest-fsfreeze-freeze now operates atomically: on success all
      freezable filesystems are frozen, and on error all filesystems are
      thawed. The ambiguous "GUEST_FSFREEZE_STATUS_ERROR" state is no
      longer entered.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      9e8aded4
  24. 13 3月, 2012 4 次提交