Compare commits

...

577 Commits

Author SHA1 Message Date
Gerd Hoffmann
d880b28cef ipxe: update to current git
Now that ipxe has separate settings for load / boot banner timeouts
re-enable the boot banner while keeping the load banner turned off,
so we don't add a delay to non-pxe boots.

git shortlog:

Adrian Jamróz (2):
      [rhine] Rewrite VIA Rhine driver
      [velocity] Rewrite VIA Velocity driver

Alex Williamson (4):
      [romprefix] Allow ROM banner timeout to be configured independently
      [autoboot] Enable infrastructure to specify an autoboot device location
      [prefix] Allow prefix to specify a PCI autoboot device location
      [romprefix] Store boot bus:dev.fn address as autoboot device location

Alexander Chernyakhovsky (1):
      [ocsp] Handle OCSP responses that don't provide certificates

Bo Yang (1):
      [build] Avoid strict-aliasing warning for gcc 4.3

Brandon Penglase (1):
      [build] Add vmware build target

Christian Hesse (2):
      [build] Update build system for Syslinux 6.x
      [build] Fix LABEL name for .liso images

Daniel P. Berrange (1):
      [zbin] Fix size used for memset in alloc_output_file

Frediano Ziglio (1):
      [romprefix] Fix incorrect pointer offset in undiloader.S

Kevin Tran (1):
      [tg3] Fix various tg3 issues

Marin Hannache (8):
      [linux] Add missing #include <stddef.h>
      [legal] Add FILE_LICENCE for valgrind headers
      [legal] Add FILE_LICENCE for core/errno.c
      [legal] Add FILE_LICENCE for ath9k driver headers
      [legal] Add missing FILE_LICENCE declarations
      [cmdline] Add "poweroff" command
      [nfs] Add support for NFS protocol
      [nfs] Fix an issue with the selection of a local port

Michael Brown (363):
      [netdevice] Separate VLAN support from presence of VLAN-supporting drivers
      [undi] Work around specific devices with known broken interrupt behaviour
      [menu] Prevent character code zero from acting as a shortcut key
      [menu] Prevent separators with shortcut keys from being selected
      [tftp] Allow TFTP block size to be controlled via the PXE TFTP API
      [pcbios] Add extra debugging messages when unhiding iPXE from memory
      [nbiprefix] Set up real-mode stack before jumping to .text16
      [prefix] Use %cs as implicit parameter to uninstall()
      [pcbios] Inhibit all calls to INT 15,e820 and INT 15,e801 during POST
      [romprefix] Display only one "Ctrl-B" prompt per PCI device during POST
      [efi] Update to latest EDK2 headers
      [autoboot] Split main control flow out of main() into a new function ipxe()
      [efi] Add last_opened_snpdev()
      [efi] Expose downloaded images via EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
      [efi] Add our own EFI_LOAD_FILE_PROTOCOL implementation
      [efi] Fix building with newer binutils
      [lkrnprefix] Allow relocation when no initrd is present
      [efi] Fix minor typos in efi_image.c
      [efi] Add EFI-specific debugging macros
      [int13] Split out ISO9660 and El Torito definitions to separate header files
      [smbios] Provide SMBIOS version number via smbios_version()
      [smbios] Mangle UUIDs for SMBIOS version 2.6 and newer
      [dhcp] Use PXE byte ordering for UUID in DHCP option 97
      [uuid] Abstract UUID mangling code out to a separate uuid_mangle() function
      [efi] Provide efi_guid_ntoa() for printing EFI GUIDs
      [efi] Add "reboot" command for EFI
      [cmdline] Add ability to perform a warm reboot
      [efi] Enable "cpuid" command by default for EFI
      [cs89x0] Remove conflicting macro definitions
      [igbvf] Remove conflicting macro definitions
      [prism2] Use standard type names
      [efi] Fetch device path for loaded image during initialisation
      [settings] Expose build architecture and platform via settings
      [bios] Fix screen clearing on buggy BIOSes
      [intel] Remove hardcoded offsets for descriptor ring registers
      [intel] Expose functionality to be shared with intelx driver
      [intel] Add intelx driver for Intel 10 Gigabit Ethernet NICs
      [efi] Remove obsolete EFI I/O implementation using EFI_CPU_IO_PROTOCOL
      [libc] Use __einfo() tuple as first argument to EUNIQ()
      [libc] Redefine low 8 bits of error code as "platform error code"
      [efi] Perform meaningful error code conversions
      [efi] Add sample platform-generated error disambiguations
      [netdevice] Use link-layer address as part of RNG seed
      [build] Allow sparse to find compiler.h
      [build] Define __WINT_TYPE__ if necessary
      [build] Allow sparse to be invoked via "make C=1"
      [build] Avoid sparse undeclared symbol warning for PROVIDE_SYMBOL()
      [process] Mark process descriptor as static in PERMANENT_PROCESS
      [realtek] Print bad MAC address in debug message when inferring no EEPROM
      [build] Use -Wno-decl when running sparse
      [build] Fix uses of literal 0 as a NULL pointer
      [build] Fix dubious uses of bitwise operators
      [build] Default to short wchar_t in stddef.h
      [realtek] Use ID word to detect EEPROM presence
      [errdb] Strip platform error code for non-platform-generated errors
      [pxe] Convert external PXE API errors into iPXE platform-generated errors
      [realtek] Allow reaction time between writing RTL_CAPR and reading RTL_CR
      [romprefix] Report failure cause when unable to open payload
      [realtek] Ensure EEPROM writes reach chip before starting udelay()
      [dhcp] Remove obsolete bootp.h header
      [netdevice] Add netdev_tx_defer() to allow drivers to defer transmissions
      [realtek] Defer packets when no transmit descriptors are available
      [settings] Eliminate settings "tag magic"
      [smbios] Allow access to unreferenced SMBIOS strings
      [smbios] Allow access to multiple instances of SMBIOS structures
      [crypto] Report meaningful error when certificate chain validation fails
      [build] Use $(eval) if available
      [build] Provide "allXXXs" targets for all media on all platforms
      [build] Add efidrv.cab target for UEFI Secure Boot signing
      [netdevice] Add "chip" setting
      [netdevice] Reset MAC address when asked to clear the "mac" setting
      [realtek] Fix reopening of legacy-mode 8139 NIC
      [crypto] Accept OCSP responses containing multiple certificates
      [bzimage] Align initrd images to page boundary
      [bzimage] Fix spurious uninitialised-variable warning on some gcc versions
      [build] Work around bug in gcc >= 4.8
      [autoboot] Use next-server from filename's settings block
      [tcp] Do not send RST for unrecognised connections
      [tcp] Fix comment to match code behaviour
      [test] Add self-tests for base16
      [base16] Generalise base16_decode() to hex_decode()
      [settings] Use hex_decode() to parse hex settings
      [settings] Add "hexraw" setting type
      [netdevice] Add "bustype" and "busloc" settings
      [settings] Add "busdevfn" setting type
      [linux] Add support for accessing PCI configuration space via /proc/bus/pci
      [settings] Add config/settings.h
      [settings] Expose PCI configuration space via settings mechanism
      [settings] Make "netX" settings block function as a symbolic link
      [cmdline] Accept "netX" in iPXE commands
      [lotest] Include sequence number within loopback test packets
      [intel] Incorporate ring producer and consumer counters in diagnostics
      [base16] Ensure base16_encode() always terminates its result string
      [realtek] Report RX error detail in debug messages
      [script] Allow for backslash continuation of script lines
      [settings] Add support for navigation keys in "config" user interface
      [realtek] Allow extra space in RX buffers
      [ifmgmt] Avoid relying on global variable within ifcommon_exec()
      [script] Avoid trying to read final character of a zero-length string
      [legal] Add missing FILE_LICENCE declarations
      [build] Fix %.licence build target
      [settings] Clarify usage of the term "named setting"
      [settings] Avoid potentially large stack allocations
      [settings] Remove temporary name buffer parameter from parse_setting_name()
      [settings] Remove default_type parameter from parse_setting_name()
      [settings] Expose parse_setting_name()
      [settings] Change "not-found" semantics of fetch_setting_copy()
      [settings] Add fetchf_setting_copy()
      [settings] Eliminate call to fetchf_named_setting() in expand_settings()
      [settings] Eliminate call to store_named_setting() in nslookup.c
      [settings] Remove now-unused store_named_setting()
      [parseopt] Allow parsed option to be modified
      [parseopt] Move parse_settings() to parseopt.c
      [parseopt] Add parse_setting()
      [settings] Eliminate call to storef_named_setting() in choose_exec()
      [settings] Eliminate calls to {fetch,store}f_named_setting() in NVO commands
      [settings] Remove now-unused fetchf_named_setting() and storef_named_setting()
      [script] Allow initial whitespace on lines containing labels
      [script] Allow commands following a script label
      [settings] Introduce the generalised concept of a numeric setting
      [cmdline] Add "inc" command
      [pci] Add pci_find_next() to iterate over existent PCI devices
      [cmdline] Add "pciscan" command to allow iteration over PCI devices
      [udp] Move high-frequency debug messages to DBGLVL_EXTRA
      [ipv6] Rename sin_{family,port} to sin6_{family,port} in struct sockaddr_in6
      [tcpip] Allow binding to unspecified privileged ports (below 1024)
      [settings] Expose CPUID instruction via settings mechanism
      [test] Add self-tests for snprintf()
      [settings] Allow numeric_setting_value() to handle long setting values
      [settings] Expose memory map via settings mechanism
      [params] Add support for the general concept of a form parameter list
      [cmdline] Add "params" and "param" commands to manage form parameter lists
      [uri] Allow URIs to incorporate a parameter list
      [http] Add support for HTTP POST
      [settings] Make built-in settings a linker table
      [linux] Give tap devices a name and bus type
      [ipv4] Generalise fragment reassembly mechanism
      [netdevice] Increase maximum network-layer address length
      [netdevice] Add concept of a network device index
      [netdevice] Add method for generating EUI-64 address from link-layer address
      [ethernet] Add support for generating multicast hash for IPv6 addresses
      [linux] Apply MAC address prior to registering network device
      [tcpip] Pass through network device to transport layer protocols
      [neighbour] Generalise concept of neighbour discovery
      [ipv4] Abstract out protocol-specific portions of "route" command
      [ipv6] Replace IPv6 stack
      [ipv6] Fix uninitialised-variable warning
      [tcp] Reduce path MTU to 1280 bytes
      [ipv6] Add inet6_aton()
      [build] Work around bug in gcc >= 4.8
      [neighbour] Add nstat() function to print out neighbour table
      [cmdline] Add "nstat" command
      [tcp] Add AF_INET6 socket opener
      [udp] Add AF_INET6 socket opener
      [netdevice] Add find_netdev_by_index()
      [socket] Add concept of a generalised socket address converter
      [ipv4] Add IPv4 socket address converter
      [ipv6] Add IPv6 socket address converter
      [resolv] Use sock_aton() to allow parsing of arbitrary numeric addresses
      [icmp] Add support for sending ICMP echo requests
      [ping] Add concept of a ping socket
      [ping] Add generic ping mechanism
      [ping] Add top-level ping() function to ping a host
      [cmdline] Add "ping" command
      [ipv6] Handle IPv6 option length correctly
      [ipv6] Extract link layer addresses from router advertisements
      [ipv6] Support stateless address autoconfiguration (SLAAC)
      [ipv6] Treat sin6_scope_id consistently
      [ipv6] Automatically choose source for link-local and multicast destinations
      [pxe] Always retrieve cached DHCPACK and apply to relevant network device
      [ipv6] Add ndp_tx_router_solicitation() to send router solicitations
      [parseopt] Add parse_timeout()
      [netdevice] Make all net_driver methods optional
      [interface] Default to calling intf_restart() in response to intf_close()
      [job] Allow job_progress() to return an ongoing job status code, if known
      [monojob] Add timeout parameter to monojob_wait()
      [monojob] Report ongoing job status as overall return status on timeout
      [cmdline] Rewrite "sync" command to use monojob_wait()
      [autoboot] Fix shell banner timeout
      [ifmgmt] Rewrite iflinkwait() to use monojob_wait()
      [cmdline] Allow "if<xxx>" commands to take options
      [netdevice] Add generic concept of a network device configurator
      [dhcp] Add DHCP network device configurator
      [parseopt] Add parse_netdev_configurator()
      [ifmgmt] Add ifconf() to carry out network device configuration
      [autoboot] Use ifconf() to configure network device
      [cmdline] Add "ifconf" command
      [cmdline] Make "dhcp" command a synonym for "ifconf"
      [dhcp] Remove obsolete dhcp() function
      [ipv6] Add IPv6 network device configurator
      [cmdline] Generate command option help text automatically
      [pxe] Ensure cached DHCPACK is retrieved prior to network device creation
      [base16] Fix comparison of signed and unsigned integers
      [settings] Move user-class setting from dhcp.c to settings.c
      [ipv6] Use given source address only if it is not the unspecified address
      [ipv6] Add "ipv6" setting type
      [dhcpv6] Add basic support for stateful and stateless DHCPv6
      [ipv6] Separate the concepts of prefix and address creation
      [dhcpv6] Allow stateful DHCPv6 to apply obtained IPv6 addresses
      [test] Include failing code within failed test result output
      [main] Defer "initialising devices" message until initialising devices
      [console] Pass escape sequence context to ANSI escape sequence handlers
      [pixbuf] Add generic concept of a pixel buffer
      [image] Allow for non-executable image formats
      [image] Add image_pixbuf() to create pixel buffer from image
      [pnm] Add support for PNM images
      [mucurses] Use "<ESC>[2J" ANSI escape sequence to clear screen
      [console] Allow console input and output to be disabled independently
      [console] Add concept of generic console configuration
      [cmdline] Add "console" command to configure console
      [fbcon] Add generic concept of a frame buffer console
      [vesafb] Add VESA frame buffer console
      [vesafb] Include raw status value within VBE error messages
      [vesafb] Skip modes for which we cannot get mode information
      [vesafb] Return meaningful error when no suitable mode is found
      [vesafb] Select an optimal mode, rather than the first acceptable mode
      [build] Fix building on OpenBSD 5.4
      [console] Allow '?' as an intermediate byte in ANSI escape sequences
      [mucurses] Implement curs_set() to control cursor visibility
      [settings] Hide cursor when not actively editing a setting
      [menu] Hide cursor when displaying menu
      [fbcon] Add support for displaying a cursor
      [settings] Explicitly separate the concept of a completed fetched setting
      [settings] Allow for IPv6 setting types in non-IPv6 builds
      [settings] Add fetch_ipv6_setting()
      [dns] Add support for resolving IPv6 addresses via AAAA records
      [socket] Ensure socket address structure sizes are fixed
      [syslog] Add support for IPv6 syslog server
      [ipv6] Add support for resolving IPv6 addresses via the "nslookup" command
      [linux] Provide access to SMBIOS via /dev/mem
      [dhcpv6] Use DUID-UUID form of client DUID
      [settings] Force settings into alphabetical order within sections
      [settings] Allow for multiple definitions of each predefined setting
      [settings] Merge SETTING_IPv4 and SETTING_IPv6
      [dhcpv6] Add DHCPv6 "filename" setting
      [ipv6] Expose NDP-provided settings (including the DNS server)
      [vesafb] Work around data corruption bug in bochs/qemu VBE implementation
      [settings] Adapt user interface to fit display size
      [login] Adapt user interface to fit display size
      [menu] Adapt user interface to fit display size
      [console] Allow consoles to update the recorded console size
      [fbcon] Update the console width and height after changing mode
      [lkrnprefix] Include iPXE version string in image header
      [fbcon] Always draw cursor using current foreground and background colours
      [console] Add centralised concept of colours and colour pairs
      [mucurses] Use centralised concept of colour pairs
      [cmdline] Add the "colour" and "cpair" commands
      [console] Add concept of a "magic" colour
      [vesafb] Set "magic" colour to transparent when a background picture is used
      [build] Remove obsolete check for GNU as version 2.9.1
      [ipv6] Fix compilation under FreeBSD
      [build] Build ROMs used by qemu and VMware as part of "make all"
      [libc] Add isprint()
      [test] Add okx() macro taking an explicit file name and line number
      [deflate] Add support for DEFLATE decompression
      [deflate] Fix literal data length calculation
      [libc] Add abs()
      [uaccess] Add memcmp_user()
      [test] Rewrite pnm_ok() using okx()
      [test] Generalise pnm_ok() to pixbuf_ok()
      [png] Add support for PNG images
      [vesafb] Handle failures from fbcon_init()
      [fbcon] Centre background picture on console
      [fbcon] Allow for an arbitrary margin around the text area
      [vesafb] Allow for an arbitrary margin around the text area
      [cmdline] Rename "console" command's --bpp option to --depth
      [cmdline] Add margin options to the "console" command
      [fbcon] Allow ANSI CUP with missing arguments
      [cmdline] Always clear screen after reconfiguring console
      [intel] Add some missing PCI IDs
      [dns] Support DNS search lists
      [dns] Update end-of-name pointer after processing CNAME record
      [dhcp] Copy exactly the required length when resizing DHCP options
      [settings] Remove "uristring" setting type
      [params] Use reference counters for form parameter lists
      [uri] Refactor URI parsing and formatting
      [image] Ensure every image has a fully resolved URI
      [tcpip] Add IP statistics collection as per RFC 4293
      [cmdline] Add the "ipstat" command
      [prefix] Ignore PCI autoboot device location if set to 00:00.0
      [tcpip] Provide tcpip_netdev() to determine the transmitting network device
      [tcpip] Provide tcpip_mtu() to determine the maximum transmission unit
      [tcp] Calculate correct MSS from peer address
      [bzimage] Report exact initrd length via bzImage header
      [realtek] Include link status register details in debug messages
      [romprefix] Do not clobber stack segment when returning to BIOS
      [netdevice] Mark devices as open before calling open() method
      [tcp] Update window even if ACK does not acknowledge new data
      [linux] Avoid starting currticks() from zero every time
      [http] Use a retry timer to trigger retried requests
      [http] Automatically retry request on a 503 Service Unavailable
      [mii] Add mii_dump() to dump all MII registers
      [realtek] Dump all MII register contents when link status changes
      [monojob] Reset timeout when progress is made
      [image] Add "--timeout" parameter to image downloading commands
      [efi] Allow for 64-bit EFI_STATUS codes
      [efi] Allow driver to be unloaded
      [efi] Connect driver to devices as part of installation
      [console] Fix display of characters with top bit set
      [lotest] Allow loopback testing on shared networks
      [netdevice] Notify upper-layer drivers when RX processing is (un)frozen
      [efi] Avoid accidentally calling main() twice
      [efi] Unload our own image before exiting UEFI application
      [efi] Disable SNP devices when running iPXE as the application
      [realtek] Add ability to dump all internal registers
      [realtek] Clear bit 24 of RCR
      [bios] Fix screen clearing on even more buggy BIOSes
      [http] Accept Content-Length header with trailing whitespace
      [crypto] Remove dynamically-allocated storage for certificate name
      [crypto] Remove dynamically-allocated storage for certificate OCSP URI
      [build] Remove long-obsolete mechanism for wrapping embedded images
      [build] Disable ccache for all relevant build targets
      [build] Add dependency of generated files upon Makefile
      [crypto] Add pubkey_match() to check for matching public/private key pairs
      [crypto] Generalise X.509 cache to a full certificate store
      [crypto] Use fingerprint when no common name is available for debug messages
      [crypto] Allow signed timestamp error margin to be configured at build time
      [test] Rewrite X.509 tests using okx()
      [test] Rewrite CMS tests using okx()
      [test] Add tests for x509_check_name()
      [test] Add subject alternative names to X.509 server test certificate
      [crypto] Add support for subjectAltName and wildcard certificates
      [crypto] Allow wildcard matches on commonName as well as subjectAltName
      [intel] Avoid completely filling the TX descriptor ring
      [test] Rewrite TCP/IP tests using okx()
      [test] Add self-tests for flsl()
      [libc] Add inline assembly implementation of flsl() using BSR instruction
      [test] Add tests for 64-bit division
      [build] Fix __libgcc attribute for recent gcc versions
      [test] Check for correct -mrtd assumption on libgcc arithmetic functions
      [libc] Add isqrt() function to find integer square roots
      [libc] Add flsll()
      [profile] Add generic profiling infrastructure
      [cmdline] Add "profstat" command to display profiling statistics
      [netdevice] Profile common operations
      [intel] Profile common virtual machine operations
      [intel] Push new RX descriptors in batches
      [librm] Use genuine real mode to accelerate operation in virtual machines
      [ipv4] Profile transmit and receive datapaths
      [tcp] Profile transmit and receive datapaths
      [http] Profile receive datapath
      [downloader] Profile receive datapath
      [build] Allow for a debug level of zero
      [librm] Allow interrupts in protected mode
      [comboot] Use built-in interrupt reflector
      [pcbios] Do not switch to real mode to check for timer interrupt
      [pcbios] Do not switch to real mode to sleep the CPU
      [test] Print out profiling statistics after a successful test run
      [librm] Add a profiling self-test for measuring mode transition times
      [librm] Add meaningful labels at section changes
      [librm] Speed up protected-to-real mode transition under KVM
      [librm] Speed up real-to-protected mode transition under KVM
      [librm] Speed up protected-mode calls under KVM
      [profile] Provide methods for profiling individual stages of operations
      [librm] Add profiling self-tests for complete real_call and prot_call cycles
      [pxe] Profile all PXE API calls
      [pxe] Profile UNDI transmit datapath
      [pxe] Work around missing PXENV_UNDI_OPEN only when necessary
      [undi] Profile all PXE API calls
      [undi] Profile transmit and receive datapaths
      [undi] Report any PXENV_UNDI_ISR errors via netdev_rx_err()
      [undi] Do not switch to real mode to check for NIC interrupt
      [undi] Place an upper limit on the number of PXENV_UNDI_ISR calls per poll

Peter Pickford (1):
      [serial] Enable UART FIFOs

Robin Smidsrød (2):
      [settings] Add "version" builtin setting
      [build] Include ipxe.pxe in default build

Stefan Hajnoczi (2):
      [netdevice] Add vlan_tag() to get the VLAN tag of a network device
      [iscsi] Include 802.1Q VLAN identifier in iBFT

Thomas Miletich (3):
      [3c90x] Stall upload engine before setting RX ring address
      [3c90x] Don't round up transmit packet length
      [3c90x] Fix High-MTU packet reception

lolipop (1):
      [intel] Add Intel I217 Gigabit Ethernet PCI ID

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-15 14:24:05 +02:00
Gerd Hoffmann
db76ec6291 seabios: update to 1.7.5-rc1
Code grew a bit, had to disable CONFIG_USB_UAS to make the
bios for the old machine types continue top fit into 128k.

git shortlog since 1.7.4:

Eric Northup (2):
      init_virtio_blk, init_virtio_scsi: reset HBA on error
      vp_init_simple: enable PCI bus-mastering before relying on DMA.

Gabriel L. Somlo (1):
      SMBIOS: Check for aggregate tables & entry point in fw_cfg

Gerd Hoffmann (4):
      smbios: catch zero-length strings
      pci: improve io address space allocation
      xhci: allocate scratch pad buffers
      vga: rework bar detection, add virtio-vga

Johannes Krampf (5):
      build: Remove unneccesary semicolons from acpi_extract scripts.
      build: Make print statements in scripts python3 compatible.
      build: Be explicit that we want integers when dividing for python3 compat.
      build: Avoid sort() on unordered classes for python3 compatibility.
      build: Be careful with unicode and byte strings for python3 compatibility.

Kevin O'Connor (79):
      build: Don't trash the .config file when src/Kconfig changes.
      Remove the pmm handle argument from _malloc().
      Clear the total block transfer count on error.
      Remove unnecesary updates of the disk op->count field.
      Always perform thread cleanup on MainThread stack.
      pvscsi: Don't store reference to struct pci_device.
      pvscsi: Always run entirely in 32bit mode.
      pvscsi: Remove use of LOWFLAT and GLOBALFLAT macros.
      usb: Replace EHCI to UHCI/OHCI synchronization with new scheme.
      Minor - pciinit.c - order header files and use static on local functions.
      Minor - fix misspelling in romfile.c comment.
      ehci: memset the qTD structures in ehci_alloc_intr_pipe
      build: Update kconfig to version in Linux 3.13.
      scripts: Allow encodeint.py to take integers in hex notation.
      coreboot: Support alternative locations for CBFS.
      debug: Add runtime option to not report the debug serial port to the OS.
      debug: Only call serial_debug_preinit() at startup.
      debug: Unify the SeaBIOS debug version banner.
      xhci: Use 64bit writes to ERDP register.
      xhci: Fix incorrect direction setting on status transmissions.
      xhci: Set the interval parameter on interrupt pipes.
      xhci: Verify PAGESIZE register before initializing driver.
      xhci: Allocate and free the xhci inctx structure on each use.
      xhci: Move set_address code from xhci_control to xhci_alloc_pipe.
      xhci: Eliminate 'struct xhci_device'.
      xhci: Support xhci controllers with 64 byte contexts.
      xhci: Allow the XHCI USB controller to be enabled for coreboot.
      xhci: Don't use a dummy endpoint count in configure command.
      xhci: Report the "protocol defined" and PSIC bits of extended capabilities.
      xhci: Support USB hubs on xhci controllers.
      Add call32_params() helper function.
      Add space between DTYPE_* definitions.
      xhci: Run the XHCI driver entirely in 32bit mode.
      Remove pci_writel() and pci_readl() functions.
      xhci: Check if scratch pad allocation fails.
      Increase maximum size of permanent high memory area.
      usb: USB 3 devices encode bMaxPacketSize0 field.
      usb: Move default pipe max packet size code from xhci to main code.
      xhci: Use the same endpoint initialization code in xhci_alloc_pipe()
      xhci: Add copyright notice to usb-xhci.c
      vgabios: Make sure exported structs use PACKED.
      vgabios: Simplify the bios save state area.
      vgabios: Simplify save/restore mechanism.
      vgabios: Attempt to detect old x86emu and force a fault.
      vgabios: Don't interpret TAB character.
      vgabios: Refactor write_teletype and write_chars.
      vgabios: Make sure stdvga_list_modes() doesn't overrun the buffer.
      coreboot: Add support for a "links" file to have aliases in CBFS.
      Enhance nullTrailingSpace() so that it can also skip leading spaces.
      coreboot: Move links file processing to its own function.
      vgabios: Fix PMM allocation request size.
      smbios: Default all values to zero.
      usb: Only disable HID devices if both USB_MOUSE and USB_KEYBOARD are off.
      Minor - fix some typos in comments.
      Replace CONFIG_THREAD_OPTIONROMS with a runtime config setting.
      acpi: Move acpi parsing logic from acpi.c to biostables.c / paravirt.c.
      smbios: Move smbios parsing logic from smbios.c to biostables.c.
      Move PirAddr definition from pirtable.c to biostables.c.
      Use biostables.c for copying bios tables even when generating them.
      Document no new changes to pirtable.c, mptable.c, acpi.c, and smbios.c.
      apm: Remove old Bochs mechanism for shutdown/suspend/standby.
      Minor - remove unused includes from pci.c.
      vgabios: Add option to control use of standard VGA IO ports.
      vgabios: Split vgafb_scroll() into separate move and clear functions.
      vgabios: Rewrite vgafb.c graphics operations to set of 4 standard operators.
      vgabios: Introduce text_address().
      vgabios: Add support for manipulating framebuffers in high memory.
      Set the color attribute when calling vgabios print character.
      vgabios: PMM scan was incorrectly depending on a zero %ds segment.
      coreboot: Make coreboot table searching available to other code.
      vgabios: Initial support for coreboot native vga vgabios.
      Minor - replace some tab characters that slipped into the code.
      Factor out smbios table walking from display_uuid to smbios_next().
      vgabios: Define PlatformRunningOn to make compile happy.
      If an int 1587 call is made from an option rom, stay in bigreal mode.
      xhci: Use msleep() instead of mdelay() for port status delay.
      build: Make sure romlayout.o is recompiled on Kconfig change.
      Fix int 1589 calls when CONFIG_ENTRY_EXTRASTACK is enabled.
      acpi: Fix acpi dsdt compile warning.

Laszlo Ersek (1):
      init_virtio_scsi(): reset the HBA before freeing its virtio ring

Marcel Apfelbaum (3):
      resume: restore piix pm config registers after resume
      hw/pci: reserve IO and mem for pci-2-pci bridges with no devices attached
      hw/pci: check if pci2pci bridges implement optional limit registers

Roger Pau Monne (1):
      ld: don't hardcode "-melf_i386"

Sander Eikelenboom (1):
      Prevent build failure by not splitting line in the middle of arguments to checkrom.py script

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-15 14:05:26 +02:00
Peter Maydell
f30d56e7d6 Merge remote-tracking branch 'remotes/rth/fix-i386' into staging
* remotes/rth/fix-i386:
  exec-all.h: Use stl_le_p instead of stl_p patching x86

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-13 18:36:19 +01:00
Richard Henderson
cb3d83bc49 exec-all.h: Use stl_le_p instead of stl_p patching x86
We got the wrong version of stl_p, the one that bswaps as appropriate
for the target.  Since x86 is always little-endian, the "_le_" routine
will resolve to what we want.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-13 10:16:07 -07:00
Peter Maydell
cd2b9b8680 Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20140512' into staging
tcg updates for 20140512

# gpg: Signature made Tue 13 May 2014 00:19:56 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/pull-tcg-20140512: (26 commits)
  tcg: Remove unreachable code in tcg_out_op and op_defs
  tcg: Use tcg_target_available_regs in tcg_reg_alloc_mov
  tcg: Make call address a constant parameter
  tci: Create tcg_out_call
  tcg-mips: Split out tcg_out_call
  tcg-sparc: Create tcg_out_call
  tcg-ppc64: Rename tcg_out_calli to tcg_out_call
  tcg-ppc: Split out tcg_out_call
  tcg-s390: Rename tgen_calli to tcg_out_call
  tcg-i386: Rename tcg_out_calli to tcg_out_call
  tcg: Require TCG_TARGET_INSN_UNIT_SIZE
  tci: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-mips: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-ia64: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-aarch64: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-arm: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-sparc: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-ppc: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-ppc64: Define TCG_TARGET_INSN_UNIT_SIZE
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-13 13:16:37 +01:00
Peter Maydell
fccae3226d bsd-user: Remove reference to CONFIG_UNAME_RELEASE
Commit e586822a5 broke the bsd-user build when it removed the
CONFIG_UNAME_RELEASE define but forgot to remove the use of it
in bsd-user. Fix this in the simplest possible way (bsd-user
doesn't make any use at all of the qemu_uname_release variable
except to allow it to be pointlessly set by the user, so this
is all we need to do.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1399648001-20980-1-git-send-email-peter.maydell@linaro.org
2014-05-13 12:48:52 +01:00
Peter Maydell
41a3f3c1bc Merge remote-tracking branch 'remotes/bonzini/configure' into staging
* remotes/bonzini/configure:
  libcacard: remove libcacard-specific CFLAGS and LIBS from global vars
  build: simplify and fix fix-obj-vars
  build: convert some obj-specific CFLAGS to use new foo.o-cflags syntax
  build: add support for per-object -cflags and -libs to all rules
  Makefile: use $(INSTALL_LIB) for modules not $(INSTALL_PROG)
  Makefile.target: use $(INSTALL_PROG) for installing, not $(INSTALL)
  Makefile: strip tools and modules too
  build: simplify Makefile.target around unnest-vars invocations
  build: simplify Makefile.target a bit, use just one rule for softmmu
  build: Fix per-object variables for Makefile.target

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-13 11:30:07 +01:00
Peter Maydell
1b5498f687 Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request

# gpg: Signature made Fri 09 May 2014 19:57:53 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  glib: fix g_poll early timeout on windows
  block: qemu-iotests - test for live migration
  block: qemu-iotests - update 085 to use common.qemu
  block: qemu-iotests - add common.qemu, for bash-controlled qemu tests
  block/raw-posix: Try both FIEMAP and SEEK_HOLE
  gluster: Correctly propagate errors when volume isn't accessible
  vl.c: remove init_clocks call from main
  block: Fix open flags with BDRV_O_SNAPSHOT
  qemu-iotests: Test converting to streamOptimized from small cluster size
  vmdk: Implement .bdrv_get_info()
  vmdk: Implement .bdrv_write_compressed
  qemu-img: Convert by cluster size if target is compressed
  block/iscsi: bump year in copyright notice
  block/nfs: Check for NULL server part
  qemu-img: sort block formats in help message
  iotests: Use configured python
  qcow2: Fix alloc_clusters_noref() overflow detection

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-13 10:35:47 +01:00
Peter Crosthwaite
e5bfd64050 microblaze: boot: Don't hack the elf entry point
There was some modulo logic to ensure that Microblaze always booted into
physical RAM regardless of the elf entry. Removed it, as QEMU should fail
gracefully when given a bad elf, rather than attempt to run it.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
2014-05-13 09:12:40 +10:00
Guenter Roeck
7dfba6dfbf xilinx_timer: Fix writes into TCSR register
The TCSR register has only 11 valid bits. This is now used by the
linux kernel to auto-detect endianness, and causes Linux 3.15-rc1
and later to hang when run under qemu-microblaze. Mask valid bits
before writing the register to solve the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2014-05-13 09:12:40 +10:00
Guenter Roeck
12f7fb6086 xilinx_intc: Fix writes into MER register
The MER register only has two valid bits. This is now used by
the linux kernel to auto-detect endianness, and causes Linux 3.15-rc1
and later to hang when run under qemu-microblaze. Mask valid bits before
writing the register to solve the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
[Edgar: Untabified]
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2014-05-13 09:12:40 +10:00
Edgar E. Iglesias
6d35556caa microblaze: Respect the reset vector
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
2014-05-13 09:12:40 +10:00
Edgar E. Iglesias
1b939d9227 microblaze: Support loading of u-boot initrd images
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
2014-05-13 09:12:40 +10:00
Richard Henderson
96d0ee7f09 tcg: Remove unreachable code in tcg_out_op and op_defs
The INDEX_op_call case has just been obsoleted; the mov and movi
cases have not been reachable for years.  Attempt to document this
both in each tcg_out_op switch, and via TCG_OPF_NOT_PRESENT.

Because of the TCG_OPF_NOT_PRESENT change, this must be done for
all targets in a single commit.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:13 -07:00
Richard Henderson
af3cbfbe80 tcg: Use tcg_target_available_regs in tcg_reg_alloc_mov
The move opcodes are special in that their constraints must cover
all available registers.  So instead of checking the constraints,
just use the available registers.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
cf06667428 tcg: Make call address a constant parameter
Avoid allocating a tcg temporary to hold the constant address,
and instead place it directly into the op_call arguments.

At the same time, convert to the newly introduced tcg_out_call
backend function, rather than invoking tcg_out_op for the call.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
dddbb2e1e3 tci: Create tcg_out_call
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
eb68a4fa4e tcg-mips: Split out tcg_out_call
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
4e9cf8409a tcg-sparc: Create tcg_out_call
Rename the existing tcg_out_calli to tcg_out_call_nodelay.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
fdd8ec7184 tcg-ppc64: Rename tcg_out_calli to tcg_out_call
Merge the existing tcg_out_call into tcg_out_op.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
00d7a1acab tcg-ppc: Split out tcg_out_call
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
a8111212b3 tcg-s390: Rename tgen_calli to tcg_out_call
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:12 -07:00
Richard Henderson
6bf3e99747 tcg-i386: Rename tcg_out_calli to tcg_out_call
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 11:13:11 -07:00
Richard Henderson
5053361b3e tcg: Require TCG_TARGET_INSN_UNIT_SIZE
Now that all backends do define TCG_TARGET_INSN_UNIT_SIZE,
remove the fallback definition.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:07:06 -07:00
Richard Henderson
a7f96f7666 tci: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:07:02 -07:00
Richard Henderson
ae0218e350 tcg-mips: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:06:58 -07:00
Richard Henderson
5588ff2921 tcg-ia64: Define TCG_TARGET_INSN_UNIT_SIZE
Using a 16-byte aligned structure achieves best results, both for code
cleanliness and compiled code size.  However, this means that we can't
use the trick of encoding the slot number into the low 2 bits.

Thankfully, we only ever use slot2, so make that explicit in the names
of the relocation functions, and drop the code for other slots.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:06:58 -07:00
Richard Henderson
8c081b1802 tcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:06:58 -07:00
Richard Henderson
8587c30c3e tcg-aarch64: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Acked-by: Claudio Fontana <claudio.fontana@huawei.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:06:52 -07:00
Richard Henderson
267c931985 tcg-arm: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:06:29 -07:00
Richard Henderson
abce5964be tcg-sparc: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Richard Henderson
38cf39f739 tcg-ppc: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Richard Henderson
e083c4a233 tcg-ppc64: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Richard Henderson
f6bff89d06 tcg-i386: Define TCG_TARGET_INSN_UNIT_SIZE
And use tcg pointer differencing functions as appropriate.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Richard Henderson
1813e1758d tcg: Define tcg_insn_unit for code pointers
To be defined by the tcg backend based on the elemental unit of the ISA.
During the transition, allow TCG_TARGET_INSN_UNIT_SIZE to be undefined,
which allows us to default tcg_insn_unit to the current uint8_t.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Richard Henderson
52a1f64ec5 tcg: Introduce byte pointer arithmetic helpers
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Peter Maydell
5c53bb8121 tcg: Avoid undefined behaviour patching code at unaligned addresses
To avoid C undefined behaviour when patching generated code,
provide wrappers tcg_patch8/16/32/64 which use the usual memcpy
trick, and use them in the i386 backend.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Peter Maydell
4387345a96 tcg: Avoid stores to unaligned addresses
Avoid stores to unaligned addresses in TCG code generation, by using the
usual memcpy() approach. (Using bswap.h would drag a lot of QEMU baggage
into TCG, so it's simpler just to do direct memcpy() here.)

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Peter Maydell
86360ad71d exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps
The code which patches x86 jump instructions assumes it can do an
unaligned write of a uint32_t. This is actually safe on x86, but it's
still undefined behaviour. We have infrastructure for doing efficient
unaligned accesses which doesn't engage in undefined behaviour, so
use it.

This is technically fractionally less efficient, at least with gcc 4.6;
instead of one instruction:
 7b2:   89 3e                   mov    %edi,(%rsi)
we get an extra spurious store to the stack slot:
 7b2:   89 7c 24 64             mov    %edi,0x64(%rsp)
 7b6:   89 3e                   mov    %edi,(%rsi)

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-12 10:03:04 -07:00
Michael Tokarev
9d171bd937 libcacard: remove libcacard-specific CFLAGS and LIBS from global vars
Currently all what's needed for single file libcacard/vcard_emul_nss.c
(libnss cflags) and hw/usb/ccid-card-emulated.c (libcacard includes)
together with the libs is added to global QEMU_CFLAGS and libs_softmmu.

Use the cflags only where really used (for two mentioned files), and
libs only where needed.

While at it, rename variables to better reflect reality: libcacard_*
is really nss_*.

This needs a bit more tweaking: $(NSS_LIBS) should not contain $glib_libs
(ditto for _cflags).  But in order to fix it, some more preparations
should be made first.  So add a FIXME comment.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-09 22:59:40 +02:00
Paolo Bonzini
2a8e6c7a85 build: simplify and fix fix-obj-vars
fix-obj-vars has the undesired side effect of breaking -cflags
-objs and -libs variables in the toplevel Makefile.objs.  The
variables in the toplevel Makefile.objs do not need any fix,
so fix-obj-vars need not do anything.

Since we are touching it, remove the now unnecessary $(if)
in the callers.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-09 22:59:40 +02:00
Sangho Park
5a007547df glib: fix g_poll early timeout on windows
g_poll has a problem on Windows when using
timeouts < 10ms, in glib/gpoll.c:

/* If not, and we have a significant timeout, poll again with
 * timeout then. Note that this will return indication for only
 * one event, or only for messages. We ignore timeouts less than
 * ten milliseconds as they are mostly pointless on Windows, the
 * MsgWaitForMultipleObjectsEx() call will timeout right away
 * anyway.
 */
if (retval == 0 && (timeout == INFINITE || timeout >= 10))
  retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, timeout);

so whenever g_poll is called with timeout < 10ms it does
a quick poll instead of wait, this causes significant performance
degradation of QEMU, thus we should use WaitForMultipleObjectsEx
directly

Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:35 +02:00
Jeff Cody
fd040174ac block: qemu-iotests - test for live migration
This is an initial, simple live migration test from one
running VM to another, using monitor commands.

This is also an example of using the new common.qemu functions
for controlling multiple running qemu instances, for tests that
need a live qemu vm.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:32 +02:00
Jeff Cody
e86e869770 block: qemu-iotests - update 085 to use common.qemu
The new functionality of common.qemu implements the QEMU control
and communication functionality that was originally in test 085.

This removes that now-duplicate functionality, and uses the
common.qemu functions.

The QEMU commandline changes slightly due to this; in addition to
monitor and qmp i/o options, the new QEMU commandline from inside
common.qemu now introduces -machine accel=qtest.

Reviewed-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:32 +02:00
Jeff Cody
e940bc13ee block: qemu-iotests - add common.qemu, for bash-controlled qemu tests
This creates some common functions for bash language qemu-iotests
to control, and communicate with, a running QEMU process.

4 functions are introduced:

    1. _launch_qemu()
        This launches the QEMU process(es), and sets up the file
        descriptors and fifos for communication.  You can choose to
        launch each QEMU process listening for either QMP or HMP
        monitor.  You can call this function multiple times, and
        save the handle returned from each.  The returned handle is
        in $QEMU_HANDLE.  You must copy this value.

Commands 2 and 3 use the handle received from _launch_qemu(), to talk
to the appropriate process.

    2. _send_qemu_cmd()
        Sends a command string, specified by $2, to QEMU.  If $3 is
        non-NULL, _send_qemu_cmd() will wait to receive $3 as a
        required result string from QEMU.  Failure to receive $3 will
        cause the test to fail.  The command can optionally be retried
        $qemu_cmd_repeat number of times.  Set $qemu_error_no_exit
        to not force the test the fail on exit; in this case,
        $QEMU_STATUS[$1] will be set to -1 on failure.

    3. _timed_wait_for()
        Waits for a response, for up to a default of 10 seconds.  If
        $2 is not seen in that time (anywhere in the response), then
        the test fails.  Primarily used by _send_qemu_cmd, but could
        be useful standalone, as well.  To prevent automatic exit
        (and therefore test failure), set $qemu_error_no_exit to a
        non-NULL value.  If $silent is a non-NULL value, then output
        to stdout will be suppressed.

    4. _cleanup_qemu()
        Kills the running QEMU processes, and removes the fifos.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:32 +02:00
Max Reitz
4f11aa8a40 block/raw-posix: Try both FIEMAP and SEEK_HOLE
The current version of raw-posix always uses ioctl(FS_IOC_FIEMAP) if
FIEMAP is available; lseek with SEEK_HOLE/SEEK_DATA are not even
compiled in in this case. However, there may be implementations which
support the latter but not the former (e.g., NFSv4.2) as well as vice
versa.

To cover both cases, try FIEMAP first (as this will return -ENOTSUP if
not supported instead of returning a failsafe value (everything
allocated as a single extent)) and if that does not work, fall back to
SEEK_HOLE/SEEK_DATA.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:32 +02:00
Peter Krempa
4557117d9e gluster: Correctly propagate errors when volume isn't accessible
The docs for glfs_init suggest that the function sets errno on every
failure. In fact it doesn't. As other functions such as
qemu_gluster_open() in the gluster block code report their errors based
on this fact we need to make sure that errno is set on each failure.

This fixes a crash of qemu-img/qemu when a gluster brick isn't
accessible from given host while the server serving the volume
description is.

Thread 1 (Thread 0x7ffff7fba740 (LWP 203880)):
 #0  0x00007ffff77673f8 in glfs_lseek () from /usr/lib64/libgfapi.so.0
 #1  0x0000555555574a68 in qemu_gluster_getlength ()
 #2  0x0000555555565742 in refresh_total_sectors ()
 #3  0x000055555556914f in bdrv_open_common ()
 #4  0x000055555556e8e8 in bdrv_open ()
 #5  0x000055555556f02f in bdrv_open_image ()
 #6  0x000055555556e5f6 in bdrv_open ()
 #7  0x00005555555c5775 in bdrv_new_open ()
 #8  0x00005555555c5b91 in img_info ()
 #9  0x00007ffff62c9c05 in __libc_start_main () from /lib64/libc.so.6
 #10 0x00005555555648ad in _start ()

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:32 +02:00
Kirill Batuzov
02ce232c50 vl.c: remove init_clocks call from main
Clocks are initialized in qemu_init_main_loop. They are not needed before it.
Initializing them twice is not only unnecessary but is harmful: it results in
memory leak and potentially can lead to a situation where different parts of
QEMU use different sets of timers.

To avoid it remove init_clocks call from main and add an assertion to
qemu_clock_init that corresponding clock has not been initialized yet.

Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:32 +02:00
Kevin Wolf
b1e6fc0817 block: Fix open flags with BDRV_O_SNAPSHOT
The immediately visible effect of this patch is that it fixes committing
a temporary snapshot to its backing file. Previously, it would fail with
a "permission denied" error because bdrv_inherited_flags() forced the
backing file to be read-only, ignoring the r/w reopen of bdrv_commit().

The bigger problem this revealed is that the original open flags must
actually only be applied to the temporary snapshot, and the original
image file must be treated as a backing file of the temporary snapshot
and get the right flags for that.

Reported-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 20:57:31 +02:00
Peter Maydell
06b4f00d53 Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp: (38 commits)
  Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()"
  qapi: Document optional arguments' backwards compatibility
  qmp: use valid JSON in transaction example
  qmp: Don't use error_is_set() to suppress additional errors
  dump: Drop pointless error_is_set(), DumpState member errp
  qemu-option: Clean up fragile use of error_is_set()
  qga: Drop superfluous error_is_set()
  qga: Clean up fragile use of error_is_set()
  qapi: Clean up fragile use of error_is_set()
  tests/qapi-schema: Drop superfluous error_is_set()
  qapi: Drop redundant, unclean error_is_set()
  hmp: Guard against misuse of hmp_handle_error()
  qga: Use return values instead of error_is_set(errp)
  error: Consistently name Error ** objects errp, and not err
  qmp: Consistently name Error ** objects errp, and not err
  qga: Consistently name Error ** objects errp, and not err
  qmp hmp: Consistently name Error * objects err, and not errp
  pci-assign: assigned_initfn(): set monitor error in common error handler
  pci-assign: propagate errors from assign_intx()
  pci-assign: propagate errors from assign_device()
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-09 15:46:34 +01:00
Peter Lieven
b690d679c1 Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()"
This reverts commit 25a7017555.

Turns out the argument *can* be null: QEMU now segfaults if it
receives an invalid parameter via a qmp command instead of throwing an
error.

For example:
{ "execute": "blockdev-add",
     "arguments": { "options" : { "driver": "invalid-driver" } } }

CC: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:32 -04:00
Eric Blake
cc1626556d qapi: Document optional arguments' backwards compatibility
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:32 -04:00
Eric Blake
cd0c5389dd qmp: use valid JSON in transaction example
Our example should use the correct quotes to match what someone
could actually pass over the wire.

* qmp-commands.hx: Use correct JSON quotes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:32 -04:00
Markus Armbruster
ab31979a7e qmp: Don't use error_is_set() to suppress additional errors
Using error_is_set(errp) that way can sweep programming errors under
the carpet when we get called incorrectly with an error set.

encrypted_bdrv_it() does it, because there's no way to make
bdrv_iterate() break its loop.  Actually safe, because qmp_cont()
clears the error before the loop.  Clean it up anyway: replace
bdrv_iterate() by bdrv_next(), break the loop on error.

Replace both occurrences, for consistency.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:32 -04:00
Markus Armbruster
66ef8bd9c1 dump: Drop pointless error_is_set(), DumpState member errp
In qmp_dump_guest_memory(), the error must be clear on entry, and we
always bail out after setting it, directly or via dump_init().
Therefore, both error_is_set() are always false.  Drop them.

DumpState member errp is now write-only.  Drop it, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:32 -04:00
Markus Armbruster
2767ceec4e qemu-option: Clean up fragile use of error_is_set()
Using error_is_set(ERRP) to find out whether to bail out due to
previous error is either wrong, fragile, or unnecessarily opaque.
It's wrong when ERRP may be null, because errors go undetected when it
is.  It's fragile when proving ERRP non-null involves a non-local
argument.  Else, it's unnecessarily opaque (see commit 84d18f0).

The error_is_set(state->errp) in qemu_opts_from_qdict_1() is merely
fragile, because the callers never pass state argument with null
state->errp.

Make the code more robust and more obviously correct: test
*state->errp directly.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:31 -04:00
Markus Armbruster
5e54769c92 qga: Drop superfluous error_is_set()
acquire_privilege(), execute_async() and check_suspend_mode() do
nothing when called with an error set.  Callers shouldn't do that, and
no caller does.  Drop the superfluous tests.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:31 -04:00
Markus Armbruster
0f230bf70e qga: Clean up fragile use of error_is_set()
Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

The error_is_set(errp) in the guest agent command handler functions
are merely fragile, because all chall chains (do_qmp_dispatch() via
the generated marshalling functions) pass a non-null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:31 -04:00
Markus Armbruster
ee16ce9337 qapi: Clean up fragile use of error_is_set()
Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

The error_is_set(errp) in do_qmp_dispatch() is merely fragile, because
the caller never passes a null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:31 -04:00
Markus Armbruster
196857f8bf tests/qapi-schema: Drop superfluous error_is_set()
visit_type_TestStruct() does nothing when called with an error set.
Callers shouldn't do that, and no caller does.  Drop the superfluous
test.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:31 -04:00
Markus Armbruster
4af8be1f88 qapi: Drop redundant, unclean error_is_set()
do_qmp_dispatch()'s test for qmp_dispatch_check_obj() failure examines
both the return value and the error object.  The latter part is
unclean; it works only when do_qmp_dispatch()'s caller passes a
non-null errp argument.  That's the case, but it's not locally
obvious.  Unclean.

Cleanup would be easy enough, but since the unclean code is also
redundant, let's just drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:31 -04:00
Markus Armbruster
415168e0c7 hmp: Guard against misuse of hmp_handle_error()
Null errp argument makes no sense.  Assert it's not null, to make this
explicit, and guard against misuse.  All current callers pass non-null
errp.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:31 -04:00
Markus Armbruster
a903f40c31 qga: Use return values instead of error_is_set(errp)
Using error_is_set(errp) to check whether a function call failed is
fragile: it breaks when errp is null.  ga_get_fd_handle() and
guest_file_handle_add() don't return a useful value when they fail,
but that's just stupid.  Fix that, and check them instead.  As far
as I can tell, errp can't be null there, but this is more robust and
more obviously correct.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:30 -04:00
Markus Armbruster
64dfefed16 error: Consistently name Error ** objects errp, and not err
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:30 -04:00
Markus Armbruster
7daecb3065 qmp: Consistently name Error ** objects errp, and not err
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:30 -04:00
Markus Armbruster
77dbc81b0f qga: Consistently name Error ** objects errp, and not err
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09 09:11:26 -04:00
Fam Zheng
10f08a0a34 qemu-iotests: Test converting to streamOptimized from small cluster size
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:17 +02:00
Fam Zheng
74fe188cd1 vmdk: Implement .bdrv_get_info()
This will return cluster_size and needs_compressed_writes to caller, if all the
extents have the same value (or there's only one extent). Otherwise return
-ENOTSUP.

cluster_size is only reported for sparse formats.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Fam Zheng
ba0ad89e2c vmdk: Implement .bdrv_write_compressed
Add a wrapper function to support "compressed" path in qemu-img convert.
Only support streamOptimized subformat case for now (num_extents == 1
and extent compression is true).

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Fam Zheng
85f49cad87 qemu-img: Convert by cluster size if target is compressed
If target block driver forces compression, qemu-img convert needs to
write by cluster size as well as "-c" option.

Particularly, this applies for converting to VMDK streamOptimized
format.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Peter Lieven
ec209aca83 block/iscsi: bump year in copyright notice
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Max Reitz
5f4d5e1aa6 block/nfs: Check for NULL server part
After the URL has been parsed make sure the server part is valid in
order to avoid a segmentation fault when calling nfs_mount().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Mike Day
1a443c1b8b qemu-img: sort block formats in help message
The help message for qemu-img lists the supported block formats, of
which there are 27 as of version 2.0.50. The formats are printed in
the order of their driver's position in a linked list, which appears
random. This patch prints the formats in sorted order, making it
easier to read and to find a specific format in the list.

[Added suggestions from Fam Zheng <famz@redhat.com> to declare variables
at the top of the scope in help() and to omit explicit cast for void*
opaque.
--Stefan]

Signed-off-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Max Reitz
f915db07ef iotests: Use configured python
Currently, QEMU's iotests rely on /usr/bin/env to start the correct
Python (that is, at least Python 2.4, but not 3). On systems where
Python 3 is the default, the user has no clean way of making the iotests
use the correct binary.

This commit makes the iotests use the Python selected by configure.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Max Reitz
65f33bc002 qcow2: Fix alloc_clusters_noref() overflow detection
If the very first allocation has a length of 0, the free_cluster_index
is still 0 after the for loop, which means that subtracting one from it
will underflow and signal an invalid range of clusters by returning
-EFBIG. However, there is no such range, as its length is 0.

Fix this by preventing underflows on free_cluster_index during the
check.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09 13:32:16 +02:00
Markus Armbruster
e940f543ae qmp hmp: Consistently name Error * objects err, and not errp
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:20:00 -04:00
Laszlo Ersek
636713bad4 pci-assign: assigned_initfn(): set monitor error in common error handler
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:20:00 -04:00
Laszlo Ersek
ef47827ac4 pci-assign: propagate errors from assign_intx()
Among the callers, only assigned_initfn() should set the  monitor's stored
error. Other callers may run in contexts where the monitor's stored error
makes no sense. For example:

assigned_dev_pci_write_config()
  assigned_dev_update_msix()
    assign_intx()

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:20:00 -04:00
Laszlo Ersek
6877cff044 pci-assign: propagate errors from assign_device()
Also, change the return type to "void"; the function is static (with a
sole caller) and the negative errno values are not distinguished from each
other.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:20:00 -04:00
Laszlo Ersek
7d9cb533f5 pci-assign: propagate errors from assigned_dev_register_regions()
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:20:00 -04:00
Laszlo Ersek
7a98593b34 pci-assign: propagate errors from assigned_dev_register_msix_mmio()
The return type is also changed from "int" to "void", because it was used
in a success vs. failure sense only (the caller didn't distinguish error
codes from each other, and even assigned_dev_register_msix_mmio() masked
mmap()'s errno values with a common -EFAULT).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:20:00 -04:00
Laszlo Ersek
64135217a7 pci-assign: propagate errors from assigned_device_pci_cap_init()
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:20:00 -04:00
Laszlo Ersek
5b877045d3 pci-assign: propagate errors from get_real_device()
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
f3455d4704 pci-assign: assignment should fail if we can't read config space
assigned_initfn()
  get_real_device()
    read()

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
42ee4194f2 pci-assign: accept Error from pci_add_capability2()
Propagate any errors while adding PCI capabilities to
assigned_device_pci_cap_init(). We'll continue the propagation upwards
when assigned_device_pci_cap_init() becomes a leaf itself (when none of
its callees will report errors internally any longer when detecting and
returning them).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
cd9aa33e2c pci: add Error-propagating pci_add_capability2()
... and rebase pci_add_capability() to it.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
665f119fba pci-assign: propagate Error from check_irqchip_in_kernel()
Rename check_irqchip_in_kernel() to verify_irqchip_in_kernel(), so that
the name reflects our expectation better. Rather than returning a bool,
make it do nothing or set an Error.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
bcdcf75d62 pci-assign: propagate errors from get_real_id()
get_real_id() has two thin wrappers (and no other callers),
get_real_vendor_id() and get_real_device_id(); it's easiest to convert
them in one fell swoop.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
4951013ff5 pci-assign: make assign_failed_examine() just format the cause
This allows us to report the entire error with one error_report() call,
easing future error propagation.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
cf10a5b18f pci-assign: accept Error from monitor_handle_fd_param2()
Propagate any errors in monitor fd handling up to get_real_device(), and
report them there. We'll continue the propagation upwards when
get_real_device() becomes a leaf itself (when none of its callees will
report errors internally any longer when detecting and returning an
error).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
eviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:59 -04:00
Laszlo Ersek
5906366ef0 monitor: add Error-propagating monitor_handle_fd_param2()
and rebase monitor_handle_fd_param() to it. (Note that this will slightly
change the behavior when the qemu_parse_fd() branch is selected and it
fails: we now report (and in case of QMP, set) the error immediately,
rather than allowing the caller to set its own error message (if any)).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:58 -04:00
Laszlo Ersek
e9c5c1f40c cutils: tighten qemu_parse_fd()
qemu_parse_fd() used to handle at least the following strings incorrectly:
o "-2":         simply let through
o "2147483648": returned as LONG_MAX==INT_MAX on ILP32 (with ERANGE
                ignored); implementation-defined behavior on LP64

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:58 -04:00
Amos Kong
cb45de6798 qapi: treat all negative return of strtosz_suffix() as error
strtosz_suffix() might return negative error, this patch fixes
the error handling.

This patch also changes to handle error in the if statement
rather than handle success specially, this will make this use
of strtosz_suffix consistent with all other uses.

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:58 -04:00
Lluís Vilanova
a719a27c82 qapi: Add a primitive to include other files from a QAPI schema file
The primitive uses JSON syntax, and include paths are relative to the file using the directive:

  { 'include': 'path/to/file.json' }

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:58 -04:00
Lluís Vilanova
33aaad529e qapi: Use an explicit input file
Use an explicit input file on the command-line instead of reading from standard
input.

It also outputs the proper file name when there's an error.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:58 -04:00
Lluís Vilanova
98c1200af1 qapi: [trivial] Do not catch unknown exceptions in "test-qapi.py"
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:58 -04:00
Lluís Vilanova
0a60774906 qapi: [trivial] Break long command lines
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08 14:19:58 -04:00
Michael Tokarev
849d8284c5 build: convert some obj-specific CFLAGS to use new foo.o-cflags syntax
Current Makefile system allows using foo.o-cflags variables to store
object-specific CFLAGS.  Convert some usages of old syntax
(using QEMU_CFLAGS += construct) to the new syntax.

Do not touch multifile modules for now, as build system isn't ready for this.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:27:49 +02:00
Paolo Bonzini
0db564eee2 build: add support for per-object -cflags and -libs to all rules
This is needed in order to use per-object flags variables.

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:27:49 +02:00
Michael Tokarev
264f8b4fdc Makefile: use $(INSTALL_LIB) for modules not $(INSTALL_PROG)
We have $(INSTALL_LIB) which is the same as $(INSTALL_PROG) but
uses correct permissions.  Loadable objects (modules) are like
shared libraries, not like programs.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:09:04 +02:00
Michael Tokarev
8f98aeb9c0 Makefile.target: use $(INSTALL_PROG) for installing, not $(INSTALL)
$(INSTALL_PROG) is evaluated to libtool if using libtool, while
$(INSTALL) is not.  Use $(INSTALL_PROG) so that libtool is used
with target too when necessary.  This allows, for example, to
link qemu with shared libcacard.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Alon Levy <alevy@redhat.com>
Cc: qemu-trivial@nongnu.org
--
This is done on top of previous patch (using $(STRIP)), but it can
be used by its own.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:09:04 +02:00
Michael Tokarev
2115182f0c Makefile: strip tools and modules too
Commit 52ba784d3 replaced $(STRIP_OPT) with $(STRIP) in some
places (for example, Makefile.target), but not all of them.
There are a few places remain in main Makefile which still
uses $(STRIP_OPT).  Replace these places with $(STRIP) too.

While at it, simplify variable pattern substitution of the
surrounding places, change $(patsubst pat,rep,$(var)) into
$(var:pat=rep) which is much easier to read (this is probably
a good idea to do everywhere).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:09:04 +02:00
Paolo Bonzini
d608cc5c53 build: simplify Makefile.target around unnest-vars invocations
No need to save/restore obj-y, we can just build all-obj-y incrementally.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:09:04 +02:00
Michael Tokarev
5c40c7395d build: simplify Makefile.target a bit, use just one rule for softmmu
On win*, we build QEMU_PROGW (GUI) and create a console app QEMU_PROG
from it, while on non-win*, we make only QEMU_PROG using the same
rules as used for QEMU_PROGW on win*.  Make just one rule for building
main executable, and an additional rule for win* to make console app
from it.  Also consolidate tests for $(QEMU_PROGW).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
[Fix user-mode compilation. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:09:04 +02:00
Paolo Bonzini
5a8b231e7e build: Fix per-object variables for Makefile.target
The compiling is done in a subdir, so the extraction of per-object libs
and cflags are referencing objects with ../ prefixed. So prefix the
per-object variables "foo.o-cflags" and "foo.o-libs" to
"../foo.o-cflags" and "../foo.o-libs".

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08 15:09:04 +02:00
Peter Maydell
43cbeffb19 Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging
Tracing pull request

# gpg: Signature made Wed 07 May 2014 18:14:02 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/tracing-pull-request:
  configure: Show trace output file conditionally
  trace: [tracetool] Minimize the amount of per-backend code
  trace: [simple] Bump up log version number
  trace: [tracetool] Change format docs to point to the generated file
  trace: [tracetool] Show list of frontends and backends sorted by name
  trace: [tracetool] Cosmetic changes
  trace: [tracetool] Spacing changes
  trace: [tracetool] Add methods 'Event.copy' and 'Arguments.copy'
  trace: [tracetool] Add method 'Event.api' to build event names

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-08 12:38:01 +01:00
Peter Maydell
6b342cc9c8 Merge remote-tracking branch 'remotes/spice/tags/pull-spice-7' into staging
spice: small fixes

# gpg: Signature made Thu 08 May 2014 09:50:21 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/spice/tags/pull-spice-7:
  spice: fix libvirt snapshots
  spice: fix "info spice"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-08 10:57:25 +01:00
Gerd Hoffmann
a76a2f729a spice: fix libvirt snapshots
Only notify spice-server about migration events in case we got
target host information beforehand.  So we kick the seamless spice
client migration only in case a actual live migration happens, not
when libvirt uses live-migration-to-file for snapshotting.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-08 10:45:54 +02:00
Gerd Hoffmann
4f60af9ac0 spice: fix "info spice"
In case no listening address was specified, "info spice" reports
"0.0.0.0" as address.  Which is incorrect in case spice is listening
on ipv6.  Replace it by a wildcard "*" to indicate it is not limited
to a specific address.

Note:  Being more specific is not possible without extending the
spice-server api.  The socket is handled by spice-server not
qemu, so qemu can't easily figure the actual socket address.

Reported-by: David Jaša <djasa@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-08 10:45:54 +02:00
Peter Maydell
ff788b6fe6 Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-05-07' into staging
trivial patches for 2014-05-07

# gpg: Signature made Wed 07 May 2014 18:01:15 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
#      Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514  66A7 BEE5 9D74 A4C3 D7DB

* remotes/mjt/tags/trivial-patches-2014-05-07: (21 commits)
  libcacard: remove unnecessary EOL from debug prints
  docs/memory.txt: Fix document on MMIO operations
  readline: Sort completions before printing them.
  readline: use g_strndup instead of open-coding it
  qmp: report path ambiguity error
  libcacard: replace pstrcpy() with memcpy()
  glib: move g_poll() replacement into glib-compat.h
  do not call g_thread_init() for glib >= 2.31
  hw/9pfs: Add include file for exported symbol
  xen: remove unused global, xen_xcg
  hw: Add missing 'static' attributes
  qemu-timer: Add missing 'static' attribute
  ui: Add missing 'static' attribute
  monitor: Add missing 'static' attribute
  hw/s390x: Add missing 'static' attribute
  hw/mips: Add missing 'static' and 'const' attributes
  hw/9pfs: Add missing 'static' attributes
  arch_init: Be sure of only one exit entry with DPRINTF() for ram_load()
  tests/tcg: Fix compilation of test_path
  qga: Fix typo (plural) in comment
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-07 18:38:39 +01:00
Peter Maydell
5894145a26 Merge remote-tracking branch 'remotes/sstabellini/xen-140507-2' into staging
* remotes/sstabellini/xen-140507-2:
  xen_disk: add discard support
  pass an inclusive address range to xc_domain_pin_memory_cacheattr
  xen: factor out common functions
  xen: move Xen HVM files under hw/i386/xen
  xen: move Xen PV machine files to hw/xenpv
  qemu-xen: free all the pirqs for msi/msix when driver unload
  exec: Limit translation limiting in address_space_translate to xen

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-07 18:12:14 +01:00
Stefan Weil
e00e36fb91 configure: Show trace output file conditionally
It is only used with the simple trace backend.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:18 +02:00
Lluís Vilanova
1dad2ce973 trace: [tracetool] Minimize the amount of per-backend code
Backends now only contain the essential backend-specific code, and most of the work is moved to frontend code.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:18 +02:00
Lluís Vilanova
ef0bd3bba6 trace: [simple] Bump up log version number
The following tracetool cleanup changes the event numbering policy.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:18 +02:00
Lluís Vilanova
30b572efd5 trace: [tracetool] Change format docs to point to the generated file
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:18 +02:00
Lluís Vilanova
b160d7f84a trace: [tracetool] Show list of frontends and backends sorted by name
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:18 +02:00
Lluís Vilanova
53158adc23 trace: [tracetool] Cosmetic changes
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:17 +02:00
Lluís Vilanova
9c24a52e29 trace: [tracetool] Spacing changes
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:17 +02:00
Lluís Vilanova
ad7443e40a trace: [tracetool] Add methods 'Event.copy' and 'Arguments.copy'
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:17 +02:00
Lluís Vilanova
7d08f0da90 trace: [tracetool] Add method 'Event.api' to build event names
Makes it easier to ensure proper naming across the different frontends and backends.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07 19:07:17 +02:00
Alon Levy
8e25c274ae libcacard: remove unnecessary EOL from debug prints
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:44 +04:00
Fam Zheng
edc1ba7a7a docs/memory.txt: Fix document on MMIO operations
.impl.valid should be .impl.unaligned and the description needs some
fixes.

.old_portio is removed since commit b40acf99b (ioport: Switch
dispatching to memory core layer).

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:44 +04:00
Hani Benhabiles
307b2f0148 readline: Sort completions before printing them.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:44 +04:00
Michael Tokarev
6ad7c326a1 readline: use g_strndup instead of open-coding it
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Färber <afaerber@suse.de>
2014-05-07 21:00:43 +04:00
Michael Tokarev
797720876a qmp: report path ambiguity error
Without this, ambiguous path is reported to the user as
"not found", which is confusing at least.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Michael Tokarev
a22f8f3894 libcacard: replace pstrcpy() with memcpy()
Commit 2e679780ae replaced strncpy() with pstrcpy()
in one place in libcacard.  This is a qemu-specific function,
while libcacard is a stand-alone library (or tries to be).
But since we know the exact length of the string to copy,
and know that it definitely will fit in the destination
buffer, use memcpy() instead, and null-terminate the string
after that.

An alternative is to use g_strlcpy() or strncpy(), but memcpy()
is more than adequate in this place.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-trivial@nongnu.org
Cc: Alon Levy <alevy@redhat.com>
2014-05-07 21:00:43 +04:00
Stefan Hajnoczi
f95c967a79 glib: move g_poll() replacement into glib-compat.h
We have a dedicated header file for wrappers to smooth over glib version
differences.  Move the g_poll() definition into glib-compat.h for
consistency.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-trivial@nongnu.org
2014-05-07 21:00:43 +04:00
Michael Tokarev
f33cc84dd4 do not call g_thread_init() for glib >= 2.31
glib >= 2.31 always enables thread support and g_thread_supported()
is #defined to 1, there's no need to call g_thread_init() anymore,
and it definitely does not need to report error which never happens.
Keep code for old < 2.31 glibc anyway for now, just #ifdef it
differently.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-trivial@nongnu.org
2014-05-07 21:00:43 +04:00
Stefan Weil
69b15212d7 hw/9pfs: Add include file for exported symbol
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Jim Meyering
770e39f743 xen: remove unused global, xen_xcg
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jim Meyering <meyering@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Stefan Weil
6a0a70b0f5 hw: Add missing 'static' attributes
This fixes warnings from the static code analysis (smatch).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Stefan Weil
fbdb664cb6 qemu-timer: Add missing 'static' attribute
This fixes a warning from the static code analysis (smatch).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Stefan Weil
6075137d94 ui: Add missing 'static' attribute
There was already a forward declaration using 'static',
but the attribute was missing in the implementation.

This fixes a warning from the static code analysis (smatch).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Stefan Weil
79f320246c monitor: Add missing 'static' attribute
This fixes a warning from the static code analysis (smatch).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Stefan Weil
bfaaad0281 hw/s390x: Add missing 'static' attribute
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Stefan Weil
f73cdbc6ac hw/mips: Add missing 'static' and 'const' attributes
This fixes a warning from the static code analysis (smatch).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Acked-by: Aurelien Jarno <aurelien@aurel32.net>
2014-05-07 21:00:43 +04:00
Stefan Weil
f5a014d236 hw/9pfs: Add missing 'static' attributes
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Chen Gang
4798fe55c4 arch_init: Be sure of only one exit entry with DPRINTF() for ram_load()
When DPRINTF() has effect, the original author wants to print all
ram_load() calling results. So need use 'goto' instead of 'return'
within ram_load(), just like other areas have done.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Peter Maydell
ad0a118fa3 tests/tcg: Fix compilation of test_path
The test_path binary is (unlike the other test binaries in tests/tcg)
actually intended to be compiled with the same compiler used to build
the main QEMU executables. It actually #includes a number of the
QEMU source files in an attempt to unit-test the util/path.c functions,
and so if it is not compiled with the same compiler used by configure
to set CONFIG_ settings then it is liable to fail to build.
Fix the makefile to build it with the default C compiler rules, not
CC_I386, and fix the test itself not to include a lot of unnecessary
trace related source files which cause the build to fail if the trace
backend is anything other than 'simple'.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Stefan Weil
8e8be266af qga: Fix typo (plural) in comment
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-05-07 21:00:43 +04:00
Michael Tokarev
4fc00556ab configure: remove bashism
Commit e26110cfc6 added a check for shacmd to create a hash
for modules.  This check in configure is using bash construct &>
to redirect both stdout and stderr, which does fun things on some
shells.  Get rid of it, use standard redirection instead.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Fam Zheng <famz@redhat.com>
2014-05-07 21:00:43 +04:00
Olaf Hering
f31352041b xen_disk: add discard support
Implement discard support for xen_disk. It makes use of the existing
discard code in qemu.

The discard support is enabled unconditionally. The tool stack may
provide a property "discard-enable" in the backend node to optionally
disable discard support.  This is helpful in case the backing file was
intentionally created non-sparse to avoid fragmentation.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2014-05-07 16:18:04 +00:00
Stefano Stabellini
8b6bb0ad17 pass an inclusive address range to xc_domain_pin_memory_cacheattr
xc_domain_pin_memory_cacheattr expects an inclusive address range:
adjust the parameters.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2014-05-07 16:17:57 +00:00
Wei Liu
04b0de0ee8 xen: factor out common functions
So common functions used by both HVM and PV are factored out from
xen-all.c to xen-common.c.

Finally rename xen-all.c to xen-hvm.c, as those functions are only
useful to HVM guest.

Create *-stub files and modify Makefile.target to reflect the changes.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2014-05-07 16:16:43 +00:00
Peter Maydell
b18a990c3d Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pc,net,MAINTAINERS,build updates

MAINTAINERS updated with link to the security process documentation
apic version modified to make more guests happy
On top of that, bugfixes all over the place

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Wed 07 May 2014 17:15:29 BST using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"

* remotes/mst/tags/for_upstream:
  configure: make source tree build more robust
  MAINTAINERS: addresses for responsible disclosure
  pm_smbus: correctly report unclaimed cycles
  smbus: return -1 if nothing found at the given address
  smbus: allow returning an error from reads
  apic: use emulated lapic version 0x14 on pc machines >= 2.1
  pc: add compat_props placeholder for 2.0 machine type
  i8259: don't abort when trying to use level sensitive irqs
  acpi: fix tables for no-hpet configuration
  acpi-build: properly decrement objects' reference counters
  acpi/pcihp.c: Rewrite acpi_pcihp_get_bsel using object_property_get_int

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-07 17:16:03 +01:00
Michael S. Tsirkin
cab00a5aa1 configure: make source tree build more robust
When source directory can be arrived at by two paths,
configure might misdetect an out of tree build.
The simplest way to trigger the problem is running
configure using a full path. E.g. (<firstpath> refers to qemu source
tree):
    ln -s <firstpath> <secondpath>
    cd <firstpath>
    <secondpath>/configure

A more practical way is when make runs configure automatically:

1. cd <firstpath>/; ./configure
    SRC_PATH=<firstpath>/ is written into config_host.mak
2. cd <secondpath>/; touch configure; make
    make now runs <firstpath>/configure, so configure
    assumes it's an out of tree build

When this happens configure overwrites parts of
the current tree with symlinks.

Make the test more robust: look for configure
in the current directory.
If there - we know it's a source build!

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 19:14:57 +03:00
Michael S. Tsirkin
62622c11f2 MAINTAINERS: addresses for responsible disclosure
Adding addresses to MAINTAINERS, as agreed on the last conference call:

http://wiki.qemu.org/SecurityProcess

People sometimes detect security issues in upstream
QEMU and don't know where to report them in a non-public way.
Of course whoever just wants full disclosure can just go public,
but there's nothing specified for non-public - until recently Anthony
was doing this informally.

As I started doing this recently anyway, I can handle this on the QEMU side
in a more formal way.

Adding a secalert mailing list as well - they are the ones who is actually
opening CVEs, communicating issues to all downstreams etc,
and they are already handling this for upstream, not just Red Hat.

Keeping Anthony's address around in case he wants to be informed.

Peter Maydell said that he prefers not to be on this contact list at
this point.

A public mailing list has been created - not listing it here yet -
until we know how to set it up in a secure fashion and
until there are more people so manually copying everyone
becomes unwieldy for reporters.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 19:14:57 +03:00
Wei Liu
ad3f7e31bf xen: move Xen HVM files under hw/i386/xen
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2014-05-07 16:14:56 +00:00
Paolo Bonzini
c8097612ce pm_smbus: correctly report unclaimed cycles
Without this patch, i2cdetect will report all addresses as present.
With it, only 0x50..0x57 are present.

Before:

         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
    10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
    20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
    30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
    40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
    50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
    60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
    70: 70 71 72 73 74 75 76 77

After:

         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: 50 51 52 53 54 55 56 57 -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 19:14:51 +03:00
Wei Liu
d5fdb85e3d xen: move Xen PV machine files to hw/xenpv
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2014-05-07 16:14:50 +00:00
Paolo Bonzini
046a184414 smbus: return -1 if nothing found at the given address
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 19:14:46 +03:00
Zhenzhong Duan
c976437c7d qemu-xen: free all the pirqs for msi/msix when driver unload
Pirqs are not freed when driver unload, then new pirqs are allocated when
driver reload. This could exhaust pirqs if do it in a loop.

This patch fixes the bug by freeing pirqs when ENABLE bit is cleared in
msi/msix control reg.

There is also other way of fixing it such as reuse pirqs between driver reload,
but this way is better.
Xen-devel: http://marc.info/?l=xen-devel&m=136800120304275&w=2

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2014-05-07 16:14:41 +00:00
Paolo Bonzini
285364e968 smbus: allow returning an error from reads
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 19:14:41 +03:00
Alexey Kardashevskiy
fe680d0dac exec: Limit translation limiting in address_space_translate to xen
The address_space_translate() function cuts the returned plen (page size)
to hardcoded TARGET_PAGE_SIZE. This function can be used on pages bigger
than that so this limiting should not be used on such pages.

Since originally the limiting was introduced for XEN, we can safely
limit this piece of code to XEN. So does the patch.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2014-05-07 16:14:36 +00:00
Gabriel L. Somlo
aa93200b88 apic: use emulated lapic version 0x14 on pc machines >= 2.1
Add "version" property to local apic, and have it default to
0x14 for pc machines starting at 2.1. For compatibility with
previous releases, pc machines up to 2.0 will have their local
apic version set to 0x11.

Signed-off-by: Gabriel L. Somlo <somlo@cmu.edu>
Acked-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 18:36:37 +03:00
Gabriel L. Somlo
9df11c9f08 pc: add compat_props placeholder for 2.0 machine type
Add the "boilerplate" necessary for subsequent patches to
simply drop in compat_props for pc machines 2.0 and older.

This patch contains no functional changes.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Acked-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 18:36:37 +03:00
Hervé Poussineau
8cbad670ce i8259: don't abort when trying to use level sensitive irqs
This is a guest-triggerable error, as seen when using Xenix 2.3.4.
Replace hw_error by LOG_UNIMPL, so that guests can continue.
With this patch, I can install and use Xenix 2.3.4a without any problem.
I can also start installation of Xenix 2.3.4q, but it fails due to not
finding an hard disk.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 18:36:37 +03:00
Peter Maydell
8d1dc5d188 Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20140507' into staging
Some improvements for s390.

Two patches deal with address translation, one fixes a problem in the
channel subsystem code.

# gpg: Signature made Wed 07 May 2014 09:29:30 BST using RSA key ID C6F02FAF
# gpg: Can't check signature: public key not found

* remotes/cohuck/tags/s390x-20140507:
  s390x/css: Don't save orb in subchannel.
  s390x/helper: Added format control bit to MMU translation
  s390x/helper: Fixed real-to-absolute address translation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-07 16:06:38 +01:00
Peter Maydell
c9541f67df Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20140505' into staging
migration/next for 20140505

# gpg: Signature made Mon 05 May 2014 21:27:24 BST using RSA key ID 5872D723
# gpg: Can't check signature: public key not found

* remotes/juanquintela/tags/migration/20140505: (36 commits)
  migration: expose xbzrle cache miss rate
  migration: expose the bitmap_sync_count to the end
  migration: Add counts of updating the dirty bitmap
  XBZRLE: Fix one XBZRLE corruption issues
  migration: remove duplicate code
  Coverity: Fix failure path for qemu_accept in migration
  Init the XBZRLE.lock in ram_mig_init
  Provide init function for ram migration
  Count used RAMBlock pages for migration_dirty_pages
  Make qemu_peek_buffer loop until it gets it's data
  Disallow outward migration while awaiting incoming migration
  virtio: validate config_len on load
  virtio-net: out-of-bounds buffer write on load
  openpic: avoid buffer overrun on incoming migration
  ssi-sd: fix buffer overrun on invalid state load
  savevm: Ignore minimum_version_id_old if there is no load_state_old
  usb: sanity check setup_index+setup_len in post_load
  vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/
  virtio-scsi: fix buffer overrun on invalid state load
  zaurus: fix buffer overrun on invalid state load
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-07 14:51:21 +01:00
Peter Maydell
7f8fea8b3d Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging
QOM/QTest infrastructure fixes and device conversions

* -device / device_add assertion fix
* QEMUMachine conversion to MachineClass
* Device error handling improvements
* QTest cleanups and test cases for some more PCI devices
* PortIO memory leak fixes

# gpg: Signature made Mon 05 May 2014 19:59:16 BST using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/qom-devices-for-peter:
  PortioList: Store PortioList in device state
  tests: Add EHCI qtest
  tests: Add ioh3420 qtest
  tests: Add intel-hda qtests
  tests: Add es1370 qtest
  tests: Add ac97 qtest
  qtest: Be paranoid about accept() addrlen argument
  qtest: Add error reporting to socket_accept()
  qtest: Assure that init_socket()'s listen() does not fail
  MAINTAINERS: Document QOM
  arm: Clean up fragile use of error_is_set() in realize() methods
  qom: Clean up fragile use of error_is_set() in set() methods
  hw: Consistently name Error ** objects errp, and not err
  hw: Consistently name Error * objects err, and not errp
  machine: Remove QEMUMachine indirection from MachineClass
  machine: Replace QEMUMachine by MachineClass in accelerator configuration
  vl.c: Replace QEMUMachine with MachineClass in QEMUMachineInitArgs
  machine: Copy QEMUMachine's fields to MachineClass
  machine: Remove obsoleted field from QEMUMachine
  qdev: Fix crash by validating the object type

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-07 13:47:26 +01:00
Michael S. Tsirkin
9ac1c4c07e acpi: fix tables for no-hpet configuration
acpi build tried to add offset of hpet table to rsdt even when hpet was
disabled.  If no tables follow hpet, this could lead to a malformed
rsdt.

Fix it up.

To avoid such errors in the future, rearrange code slightly to make it
clear that acpi_add_table stores the offset of the following table - not
of the previous one.

Reported-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: qemu-stable@nongnu.org
2014-05-07 12:13:42 +03:00
Kirill Batuzov
097a97a665 acpi-build: properly decrement objects' reference counters
Object returned by object_property_get_qobject needs its reference counter to
be decremented when it is not needed by caller anymore.

Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 12:13:42 +03:00
Kirill Batuzov
7c38ecd097 acpi/pcihp.c: Rewrite acpi_pcihp_get_bsel using object_property_get_int
acpi_pcihp_get_bsel implements functionality of object_property_get_int for
specific property named ACPI_PCIHP_PROP_BSEL, but fails to decrement object's
reference counter properly. Rewriting it using generic object_property_get_int
serves two purposes: reducing code duplication and fixing memory leak.

Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-05-07 12:13:42 +03:00
Cornelia Huck
56bf1a8e90 s390x/css: Don't save orb in subchannel.
Current css code saves the operation request block (orb) in the
subchannel structure for later consumption by the start function
handler. This might make sense for asynchronous execution of the
start function (which qemu doesn't support), but not in our case;
it would even be wrong since orb contains a reference to a local
variable in the base ssch handler.

Let's just pass the orb through the start function call chain for
ssch; for rsch, we can pass NULL as the backend function does not
use any information passed via the orb there.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-05-07 10:17:35 +02:00
Thomas Huth
c4400206d4 s390x/helper: Added format control bit to MMU translation
With the EDAT-1 facility, the MMU translation can stop at the
segment table already, pointing to a 1 MB block. And while we're
at it, move the page table entry handling to a separate function,
too, as suggested by Alexander Graf.

Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-05-07 10:17:35 +02:00
Thomas Huth
422f32c5b1 s390x/helper: Fixed real-to-absolute address translation
The real-to-absolute address translation in mmu_translate() was
missing the second part for translating the page at the prefix
address back to the 0 page. And while we're at it, also moved the
code into a separate helper function since this might come in
handy for other parts of the code, too.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-05-07 10:17:35 +02:00
Peter Maydell
951916d02c Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-6' into staging
ohci live migration.
mtp bugfixes.

# gpg: Signature made Mon 05 May 2014 12:08:48 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-usb-6:
  usb: mtp: reply INCOMPLETE_TRANSFER on read errors
  usb: mtp: fix possible buffer overflow
  usb: mtp: drop data-out hexdump
  usb: mtp: avoid empty description string
  usb: mtp: fix error path memory leak
  usb: mtp: fix serial (must be exact 32 chars)
  usb: mtp: fix version (is decimal not bcd)
  usb: mtp: fix usb_mtp_add_u64
  usb: mtp: replace debug printfs with trace points
  usb-ohci: Add vmstate descriptor

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-06 13:06:32 +01:00
Peter Maydell
9898370497 Merge remote-tracking branch 'remotes/kraxel/tags/pull-smbios-2' into staging
smbios: make qemu generate smbios tables.

# gpg: Signature made Mon 05 May 2014 12:20:27 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-smbios-2:
  SMBIOS: Build aggregate smbios tables and entry point
  SMBIOS: Use bitmaps to prevent incompatible comand line options
  SMBIOS: Use macro to set smbios defaults
  SMBIOS: Update header file definitions
  SMBIOS: Rename symbols to better reflect future use
  E820: Add interface for accessing e820 table
  pc: add 2.1 machine type

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-06 12:23:05 +01:00
Peter Maydell
03e2bfee37 Merge remote-tracking branch 'remotes/rth/tgt-axp' into staging
* remotes/rth/tgt-axp:
  target-alpha: Fix RDUSP

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-06 11:57:46 +01:00
Peter Maydell
cf972928fc Merge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging
* remotes/riku/linux-user-for-upstream:
  linux-user: fix getrusage and wait4 failures with invalid rusage struct
  linux-user/elfload.c: Support ARM HWCAP2 flags
  linux-user/elfload.c: Fix A64 code which was incorrectly acting like A32
  linux-user/elfload.c: Update ARM HWCAP bits
  linux-user/elfload.c: Fix incorrect ARM HWCAP bits
  linux-user: remove configure option for setting uname release
  linux-user: move uname functions to uname.c
  linux-user: rename cpu-uname -> uname
  linux-user/signal.c: Set fault address in AArch64 signal info
  linux-user: avoid using glibc internals in _syscall5 and in definition of target_sigevent struct
  linux-user: Handle arches with llseek instead of _llseek
  linux-user: Add support for SCM_CREDENTIALS.
  linux-user: Move if-elses to a switch statement.
  linux-user: Assert stack used for auxvec, envp, argv
  linux-user: Add /proc/self/exe open forwarding

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-06 10:56:38 +01:00
ChenLiang
8bc3923343 migration: expose xbzrle cache miss rate
expose xbzrle cache miss rate

Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
ChenLiang
58570ed894 migration: expose the bitmap_sync_count to the end
expose the count that logs the times of updating the dirty bitmap to
end user.

Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
ChenLiang
71411d3580 migration: Add counts of updating the dirty bitmap
Add counts to log the times of updating the dirty bitmap.

Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
ChenLiang
1534ee93cc XBZRLE: Fix one XBZRLE corruption issues
The page may not be inserted into cache after executing save_xbzrle_page.
In case of failure to insert, the original page should be sent rather
than the page in the cache.

Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
ChenLiang
21a246a43b migration: remove duplicate code
version_id is checked twice in the ram_load.

Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Dr. David Alan Gilbert
d99598cc99 Coverity: Fix failure path for qemu_accept in migration
Coverity defects 1005733 & 1005734 complain about passing a negative
value to closesocket in the error paths on incoming migration.

Stash the error value and print it in the message (previously we gave
no indication of the reason for the failure)

Use error_report

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Dr. David Alan Gilbert
d97326eec2 Init the XBZRLE.lock in ram_mig_init
Initialising the XBZRLE.lock earlier simplifies the lock use.

Based on Markus's patch in:
http://lists.gnu.org/archive/html/qemu-devel/2014-03/msg03879.html

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Dr. David Alan Gilbert
0d6ab3ab91 Provide init function for ram migration
Provide ram_mig_init (like blk_mig_init) for vl.c to initialise stuff
to do with ram migration (currently in arch_init.c).

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Dr. David Alan Gilbert
e30d1d8c71 Count used RAMBlock pages for migration_dirty_pages
This is a fix for a bug* triggered by a migration after hot unplugging
a few virtio-net NICs, that caused migration never to converge, because
'migration_dirty_pages' is incorrectly initialised.

'migration_dirty_pages' is used as a tally of the number of outstanding
dirty pages, to give the migration code an idea of how much more data
will need to be transferred, and thus whether it can end the iterative
phase.

It was initialised to the total size of the RAMBlock address space,
however hotunplug can leave this space sparse, and hence
migration_dirty_pages ended up too large.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

(* https://bugzilla.redhat.com/show_bug.cgi?id=1074913 )

Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Dr. David Alan Gilbert
548f52ea06 Make qemu_peek_buffer loop until it gets it's data
Make qemu_peek_buffer repeatedly call fill_buffer until it gets
all the data it requires, or until there is an error.

  At the moment, qemu_peek_buffer will try one qemu_fill_buffer if there
  isn't enough data waiting, however the kernel is entitled to return
  just a few bytes, and still leave qemu_peek_buffer with less bytes
  than it needed.  I've seen this fail in a dev world, and I think it
  could theoretically fail in the peeking of the subsection headers in
  the current world.

Comment qemu_peek_byte to point out it's not guaranteed to work for
  non-continuous peeks

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: ChenLiang <chenliang0016@icloud.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Dr. David Alan Gilbert
ca99993adc Disallow outward migration while awaiting incoming migration
QEMU will assert if you attempt to start an outgoing migration on
a QEMU that's sitting waiting for an incoming migration (started
with -incoming), so disallow it with a proper error.

(This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1086987 )

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Michael S. Tsirkin
a890a2f913 virtio: validate config_len on load
Malformed input can have config_len in migration stream
exceed the array size allocated on destination, the
result will be heap overflow.

To fix, that config_len matches on both sides.

CVE-2014-0182

Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

--

v2: use %ix and %zx to print config_len values
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Michael S. Tsirkin
98f93ddd84 virtio-net: out-of-bounds buffer write on load
CVE-2013-4149 QEMU 1.3.0 out-of-bounds buffer write in
virtio_net_load()@hw/net/virtio-net.c

>         } else if (n->mac_table.in_use) {
>             uint8_t *buf = g_malloc0(n->mac_table.in_use);

We are allocating buffer of size n->mac_table.in_use

>             qemu_get_buffer(f, buf, n->mac_table.in_use * ETH_ALEN);

and read to the n->mac_table.in_use size buffer n->mac_table.in_use *
ETH_ALEN bytes, corrupting memory.

If adversary controls state then memory written there is controlled
by adversary.

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Michael Roth
73d963c0a7 openpic: avoid buffer overrun on incoming migration
CVE-2013-4534

opp->nb_cpus is read from the wire and used to determine how many
IRQDest elements to read into opp->dst[]. If the value exceeds the
length of opp->dst[], MAX_CPU, opp->dst[] can be overrun with arbitrary
data from the wire.

Fix this by failing migration if the value read from the wire exceeds
MAX_CPU.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Michael S. Tsirkin
a9c380db3b ssi-sd: fix buffer overrun on invalid state load
CVE-2013-4537

s->arglen is taken from wire and used as idx
in ssi_sd_transfer().

Validate it before access.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Peter Maydell
767adce2d9 savevm: Ignore minimum_version_id_old if there is no load_state_old
At the moment we require vmstate definitions to set minimum_version_id_old
to the same value as minimum_version_id if they do not provide a
load_state_old handler. Since the load_state_old functionality is
required only for a handful of devices that need to retain migration
compatibility with a pre-vmstate implementation, this means the bulk
of devices have pointless boilerplate. Relax the definition so that
minimum_version_id_old is ignored if there is no load_state_old handler.

Note that under the old scheme we would segfault if the vmstate
specified a minimum_version_id_old that was less than minimum_version_id
but did not provide a load_state_old function, and the incoming state
specified a version number between minimum_version_id_old and
minimum_version_id. Under the new scheme this will just result in
our failing the migration.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Michael S. Tsirkin
9f8e9895c5 usb: sanity check setup_index+setup_len in post_load
CVE-2013-4541

s->setup_len and s->setup_index are fed into usb_packet_copy as
size/offset into s->data_buf, it's possible for invalid state to exploit
this to load arbitrary data.

setup_len and setup_index should be checked to make sure
they are not negative.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Michael S. Tsirkin
3476436a44 vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/
As the macro verifies the value is positive, rename it
to make the function clearer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:03 +02:00
Michael S. Tsirkin
3c3ce98142 virtio-scsi: fix buffer overrun on invalid state load
CVE-2013-4542

hw/scsi/scsi-bus.c invokes load_request.

 virtio_scsi_load_request does:
    qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));

this probably can make elem invalid, for example,
make in_num or out_num huge, then:

    virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);

will do:

    if (req->elem.out_num > 1) {
        qemu_sgl_init_external(req, &req->elem.out_sg[1],
                               &req->elem.out_addr[1],
                               req->elem.out_num - 1);
    } else {
        qemu_sgl_init_external(req, &req->elem.in_sg[1],
                               &req->elem.in_addr[1],
                               req->elem.in_num - 1);
    }

and this will access out of array bounds.

Note: this adds security checks within assert calls since
SCSIBusInfo's load_request cannot fail.
For now simply disable builds with NDEBUG - there seems
to be little value in supporting these.

Cc: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
52f91c3723 zaurus: fix buffer overrun on invalid state load
CVE-2013-4540

Within scoop_gpio_handler_update, if prev_level has a high bit set, then
we get bit > 16 and that causes a buffer overrun.

Since prev_level comes from wire indirectly, this can
happen on invalid state load.

Similarly for gpio_level and gpio_dir.

To fix, limit to 16 bit.

Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
5193be3be3 tsc210x: fix buffer overrun on invalid state load
CVE-2013-4539

s->precision, nextprecision, function and nextfunction
come from wire and are used
as idx into resolution[] in TSC_CUT_RESOLUTION.

Validate after load to avoid buffer overrun.

Cc: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
ead7a57df3 ssd0323: fix buffer overun on invalid state load
CVE-2013-4538

s->cmd_len used as index in ssd0323_transfer() to store 32-bit field.
Possible this field might then be supplied by guest to overwrite a
return addr somewhere. Same for row/col fields, which are indicies into
framebuffer array.

To fix validate after load.

Additionally, validate that the row/col_start/end are within bounds;
otherwise the guest can provoke an overrun by either setting the _end
field so large that the row++ increments just walk off the end of the
array, or by setting the _start value to something bogus and then
letting the "we hit end of row" logic reset row to row_start.

For completeness, validate mode as well.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
caa881abe0 pxa2xx: avoid buffer overrun on incoming migration
CVE-2013-4533

s->rx_level is read from the wire and used to determine how many bytes
to subsequently read into s->rx_fifo[]. If s->rx_level exceeds the
length of s->rx_fifo[] the buffer can be overrun with arbitrary data
from the wire.

Fix this by validating rx_level against the size of s->rx_fifo.

Cc: Don Koch <dkoch@verizon.com>
Reported-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Don Koch <dkoch@verizon.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
36cf2a3713 virtio: validate num_sg when mapping
CVE-2013-4535
CVE-2013-4536

Both virtio-block and virtio-serial read,
VirtQueueElements are read in as buffers, and passed to
virtqueue_map_sg(), where num_sg is taken from the wire and can force
writes to indicies beyond VIRTQUEUE_MAX_SIZE.

To fix, validate num_sg.

Reported-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael Roth
4b53c2c72c virtio: avoid buffer overrun on incoming migration
CVE-2013-6399

vdev->queue_sel is read from the wire, and later used in the
emulation code as an index into vdev->vq[]. If the value of
vdev->queue_sel exceeds the length of vdev->vq[], currently
allocated to be VIRTIO_PCI_QUEUE_MAX elements, subsequent PIO
operations such as VIRTIO_PCI_QUEUE_PFN can be used to overrun
the buffer with arbitrary data originating from the source.

Fix this by failing migration if the value from the wire exceeds
VIRTIO_PCI_QUEUE_MAX.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
d2ef4b61fe vmstate: fix buffer overflow in target-arm/machine.c
CVE-2013-4531

cpreg_vmstate_indexes is a VARRAY_INT32. A negative value for
cpreg_vmstate_array_len will cause a buffer overflow.

VMSTATE_INT32_LE was supposed to protect against this
but doesn't because it doesn't validate that input is
non-negative.

Fix this macro to valide the value appropriately.

The only other user of VMSTATE_INT32_LE doesn't
ever use negative numbers so it doesn't care.

Reported-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
d8d0a0bc7e pl022: fix buffer overun on invalid state load
CVE-2013-4530

pl022.c did not bounds check tx_fifo_head and
rx_fifo_head after loading them from file and
before they are used to dereference array.

Reported-by: Michael S. Tsirkin <mst@redhat.com
Reported-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
5f691ff91d hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
4) CVE-2013-4529
hw/pci/pcie_aer.c    pcie aer log can overrun the buffer if log_num is
                     too large

There are two issues in this file:
1. log_max from remote can be larger than on local
then buffer will overrun with data coming from state file.
2. log_num can be larger then we get data corruption
again with an overflow but not adversary controlled.

Fix both issues.

Reported-by: Anthony Liguori <anthony@codemonkey.ws>
Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
3f1c49e213 hpet: fix buffer overrun on invalid state load
CVE-2013-4527 hw/timer/hpet.c buffer overrun

hpet is a VARRAY with a uint8 size but static array of 32

To fix, make sure num_timers is valid using VMSTATE_VALID hook.

Reported-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
ae2158ad6c ahci: fix buffer overrun on invalid state load
CVE-2013-4526

Within hw/ide/ahci.c, VARRAY refers to ports which is also loaded.  So
we use the old version of ports to read the array but then allow any
value for ports.  This can cause the code to overflow.

There's no reason to migrate ports - it never changes.
So just make sure it matches.

Reported-by: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Michael S. Tsirkin
cc45995294 virtio: out-of-bounds buffer write on invalid state load
CVE-2013-4151 QEMU 1.0 out-of-bounds buffer write in
virtio_load@hw/virtio/virtio.c

So we have this code since way back when:

    num = qemu_get_be32(f);

    for (i = 0; i < num; i++) {
        vdev->vq[i].vring.num = qemu_get_be32(f);

array of vqs has size VIRTIO_PCI_QUEUE_MAX, so
on invalid input this will write beyond end of buffer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 22:15:02 +02:00
Kirill Batuzov
848696bf35 PortioList: Store PortioList in device state
PortioList is an abstraction used for construction of MemoryRegionPortioList
from MemoryRegionPortio. It can be used later to unmap created memory regions.
It also requires proper cleanup because some of the memory inside is allocated
dynamically.

By moving PortioList ot device state we make it possible to cleanup later and
avoid leaking memory.

This change spans several target platforms.  The following testcases cover all
changed lines:
  qemu-system-ppc -M prep
  qemu-system-i386 -vga qxl
  qemu-system-i386 -M isapc -soundhw adlib -device ib700,id=watchdog0,bus=isa.0

Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
cc900d34e7 tests: Add EHCI qtest
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
efbf5df020 tests: Add ioh3420 qtest
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
fbaf445a89 tests: Add intel-hda qtests
Test both the ich6 and the ich9 version (cf. q35 config) and all the
codecs.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
8fa74c947d tests: Add es1370 qtest
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
d7b50c0cc0 tests: Add ac97 qtest
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
535b45631a qtest: Be paranoid about accept() addrlen argument
POSIX specifies that address_len shall on output specify the length of
the stored address; it does not however specify whether it may get
updated on failure as well to, e.g., zero.

In case EINTR occurs, re-initialize the variable to the desired value.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
a7d915f388 qtest: Add error reporting to socket_accept()
We're not using the GLib infrastructure here, to allow cleaning up the
sockets. Still, knowing why a certain test run failed can be valuable.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
a7ded163db qtest: Assure that init_socket()'s listen() does not fail
In practice this seems very unlikely, so cleanup is neglected, as done
for bind().

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Andreas Färber
4688c94c1f MAINTAINERS: Document QOM
Invented by Anthony. Maintained through my qom-next tree lately.

Cc: Anthony Liguori <aliguori@amazon.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 20:58:33 +02:00
Markus Armbruster
0175ba109e arm: Clean up fragile use of error_is_set() in realize() methods
Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

I guess the error_is_set(errp) in the DeviceClass realize() methods
are merely fragile right now, because I can't find a call chain that
passes a null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Markus Armbruster
65cd9064e1 qom: Clean up fragile use of error_is_set() in set() methods
Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

I guess the error_is_set(errp) in the ObjectProperty set() methods are
merely fragile right now, because I can't find a call chain that
passes a null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Markus Armbruster
a7737e4496 hw: Consistently name Error ** objects errp, and not err
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Markus Armbruster
2f719f195c hw: Consistently name Error * objects err, and not errp
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Marcel Apfelbaum
958db90cd5 machine: Remove QEMUMachine indirection from MachineClass
No need to go through qemu_machine field. Use
MachineClass fields directly.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Marcel Apfelbaum
f1e298794d machine: Replace QEMUMachine by MachineClass in accelerator configuration
This minimizes QEMUMachine usage, as part of machine QOM-ification.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Marcel Apfelbaum
aaa663916d vl.c: Replace QEMUMachine with MachineClass in QEMUMachineInitArgs
QEMUMachine's fields are already in MachineClass. We can safely
make the switch because we copy them in machine_class_init() and
spapr_machine_class_init().

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Marcel Apfelbaum
00b4fbe274 machine: Copy QEMUMachine's fields to MachineClass
In order to eliminate the QEMUMachine indirection,
add its fields directly to MachineClass.
Do not yet remove qemu_machine field because it is
still in use by sPAPR.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
[AF: Copied fields for sPAPR, too]
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Marcel Apfelbaum
9e1d668ba9 machine: Remove obsoleted field from QEMUMachine
This field shouldn't be used any more since we
adopted the QOM way of iterating over the types.

The commit that obsoleted it is:
commit 261747f176
    vl: Use MachineClass instead of global QEMUMachine list

    The machine registration flow is refactored to use the QOM functionality.
    Instead of linking the machines into a list, each machine has a type
    and the types can be traversed in the QOM way.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Amos Kong
ce0abca3e3 qdev: Fix crash by validating the object type
QEMU crashed when I try to list device parameters and the driver name is
actually an available bus name.

 # qemu -device virtio-pci-bus,?
 # qemu -device virtio-bus,?
 # qemu -device virtio-serial-bus,?
 qdev-monitor.c:212:qdev_device_help: Object 0x7fd932f50620 is not an
 instance of type device
 Aborted (core dumped)

We can also reproduce this bug by adding device from monitor, so it's
worth to fix the crash.

 (qemu) device_add virtio-serial-bus
 qdev-monitor.c:491:qdev_device_add: Object 0x7f5e89530920 is not an
 instance of type device
 Aborted (core dumped)

Cc: qemu-stable@nongnu.org
Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-05-05 19:08:49 +02:00
Petar Jovanovic
a39fb273bd linux-user: fix getrusage and wait4 failures with invalid rusage struct
Implementations of system calls getrusage and wait4 have not previously
handled correctly cases when incorrect address of struct rusage is
passed.
This change makes sure return values are correctly set for these cases.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-05 15:21:05 +03:00
Michael S. Tsirkin
eea750a562 virtio-net: out-of-bounds buffer write on invalid state load
CVE-2013-4150 QEMU 1.5.0 out-of-bounds buffer write in
virtio_net_load()@hw/net/virtio-net.c

This code is in hw/net/virtio-net.c:

    if (n->max_queues > 1) {
        if (n->max_queues != qemu_get_be16(f)) {
            error_report("virtio-net: different max_queues ");
            return -1;
        }

        n->curr_queues = qemu_get_be16(f);
        for (i = 1; i < n->curr_queues; i++) {
            n->vqs[i].tx_waiting = qemu_get_be32(f);
        }
    }

Number of vqs is max_queues, so if we get invalid input here,
for example if max_queues = 2, curr_queues = 3, we get
write beyond end of the buffer, with data that comes from
wire.

This might be used to corrupt qemu memory in hard to predict ways.
Since we have lots of function pointers around, RCE might be possible.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 14:15:10 +02:00
Michael S. Tsirkin
71f7fe48e1 virtio-net: fix buffer overflow on invalid state load
CVE-2013-4148 QEMU 1.0 integer conversion in
virtio_net_load()@hw/net/virtio-net.c

Deals with loading a corrupted savevm image.

>         n->mac_table.in_use = qemu_get_be32(f);

in_use is int so it can get negative when assigned 32bit unsigned value.

>         /* MAC_TABLE_ENTRIES may be different from the saved image */
>         if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {

passing this check ^^^

>             qemu_get_buffer(f, n->mac_table.macs,
>                             n->mac_table.in_use * ETH_ALEN);

with good in_use value, "n->mac_table.in_use * ETH_ALEN" can get
positive and bigger than mac_table.macs. For example 0x81000000
satisfies this condition when ETH_ALEN is 6.

Fix it by making the value unsigned.
For consistency, change first_multi as well.

Note: all call sites were audited to confirm that
making them unsigned didn't cause any issues:
it turns out we actually never do math on them,
so it's easy to validate because both values are
always <= MAC_TABLE_ENTRIES.

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 14:15:10 +02:00
Michael S. Tsirkin
4082f0889b vmstate: add VMSTATE_VALIDATE
Validate state using VMS_ARRAY with num = 0 and VMS_MUST_EXIST

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 14:15:10 +02:00
Michael S. Tsirkin
5bf81c8d63 vmstate: add VMS_MUST_EXIST
Can be used to verify a required field exists or validate
state in some other way.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 14:15:10 +02:00
Michael S. Tsirkin
35fc1f7189 vmstate: reduce code duplication
move size offset and number of elements math out
to functions, to reduce code duplication.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2014-05-05 14:15:10 +02:00
Gabriel L. Somlo
c97294ec1b SMBIOS: Build aggregate smbios tables and entry point
Build an aggregate set of smbios tables and an entry point structure.

Insert tables and entry point into fw_cfg respectively under
"etc/smbios/smbios-tables" and "etc/smbios/smbios-anchor".

Machine types <= 2.0 will for now continue using field-by-field
overrides to SeaBIOS defaults, but for machine types 2.1 and up we
expect the BIOS to look for and use the aggregate tables generated
by this patch.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>

[ kraxel: fix 32bit build ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 13:14:48 +02:00
Gerd Hoffmann
8ebb876357 usb: mtp: reply INCOMPLETE_TRANSFER on read errors
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:58:02 +02:00
Gerd Hoffmann
afa82daf16 usb: mtp: fix possible buffer overflow
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:58 +02:00
Gerd Hoffmann
9cd04ccf75 usb: mtp: drop data-out hexdump
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:53 +02:00
Gerd Hoffmann
457d397a24 usb: mtp: avoid empty description string
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:49 +02:00
Gerd Hoffmann
2dc7fdf33d usb: mtp: fix error path memory leak
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:45 +02:00
Gerd Hoffmann
9e4eff5b54 usb: mtp: fix serial (must be exact 32 chars)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:41 +02:00
Gerd Hoffmann
f7eaed8555 usb: mtp: fix version (is decimal not bcd)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:35 +02:00
Gerd Hoffmann
ada435f47e usb: mtp: fix usb_mtp_add_u64
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:30 +02:00
Gerd Hoffmann
1c76551fae usb: mtp: replace debug printfs with trace points
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-05 12:57:21 +02:00
Alexey Kardashevskiy
69e25d26b4 usb-ohci: Add vmstate descriptor
This adds migration support for OHCI.

This defines a descriptor for OHCIState.
This changes some OHCIState field types to be migration compatible.
This adds a descriptor for OHCIPort.
This migrates the EOF timer if the USB was started at the time of
migration.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 12:29:41 +02:00
Gabriel L. Somlo
2e6e8d7a25 SMBIOS: Use bitmaps to prevent incompatible comand line options
Replace existing smbios_check_collision() functionality with
a pair of bitmaps: have_binfile_bitmap and have_fields_bitmap.
Bits corresponding to each smbios type are set by smbios_entry_add(),
which also uses the bitmaps to ensure that binary blobs and field
values are never accepted for the same type.

These bitmaps will also be used in the future to decide whether
or not to build a full table for a given smbios type.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 12:29:39 +02:00
Gabriel L. Somlo
cb36acb672 SMBIOS: Use macro to set smbios defaults
The function smbios_set_defaults() uses a repeating code pattern
for each field. This patch replaces that pattern with a macro.

This patch contains no functional changes.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 12:29:39 +02:00
Gabriel L. Somlo
e41fca3da7 SMBIOS: Update header file definitions
Add definitions for smbios entry point (anchor), and for type 2
(base board) structure which is required by some versions of OS X.

Remove definition for type 20 (memory device mapped address)
structure, which is no longer required as of smbios spec v2.5.

Update all other structure definitions to bring them into
compliance with smbios spec v2.8.

This patch contains no functional changes.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 12:29:39 +02:00
Gabriel L. Somlo
e6667f719c SMBIOS: Rename symbols to better reflect future use
Rename the following symbols:

  - smbios_set_type1_defaults() to the more general smbios_set_defaults();
  - bool smbios_type1_defaults to the more general smbios_defaults;
  - smbios_get_table() to smbios_get_table_legacy();

This patch contains no functional changes.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 12:29:39 +02:00
Gabriel L. Somlo
7bf8ef196e E820: Add interface for accessing e820 table
Add the following two functions:

  - e820_get_num_entries() - query the size of the e820 table
  - e820_get_entry() - grab an entry matching a given set of criteria

This interface is currently necessary for creating type 19
(memory array mapped address) structures in smbios.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 12:29:39 +02:00
Michael S. Tsirkin
3458b2b075 pc: add 2.1 machine type
At the moment, 2.1 and 2.0 machines are identical.
As several people are working on incompatible changes
to the PC machine, collaboration will be made easier
by merging this place-holder.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-05 12:29:39 +02:00
Richard Henderson
214bb280c6 target-alpha: Fix RDUSP
Commit 06ef8604e9 contained a typo.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-05-02 20:42:02 -07:00
Peter Maydell
ad6919dc0a linux-user/elfload.c: Support ARM HWCAP2 flags
The ARM kernel has chosen to spill into the HWCAP2 ELF feature bit flags
early, even though it hasn't yet exhausted all 32 bits of the HWCAP word.
Add support for setting this in the same way we do for HWCAP.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Peter Maydell
24e76ff06b linux-user/elfload.c: Fix A64 code which was incorrectly acting like A32
The ARM target-specific code in elfload.c was incorrectly allowing
the 64-bit ARM target to use most of the existing 32-bit definitions:
most noticably this meant that our HWCAP bits passed to the guest
were wrong, and register handling when dumping core was totally
broken. Fix this by properly separating the 64 and 32 bit code,
since they have more differences than similarities.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Peter Maydell
2468265465 linux-user/elfload.c: Update ARM HWCAP bits
The kernel has added support for a number of new ARM HWCAP bits;
add them to QEMU, including support for setting them where we have
a corresponding CPU feature bit.

We were also incorrectly setting the VFPv3D16 HWCAP -- this means
"only 16 D registers", not "supports 16-bit floating point format";
since QEMU always has 32 D registers for VFPv3, we can just remove
the line that incorrectly set this bit.

The kernel does not set the HWCAP_FPA even if it is providing FPA
emulation via nwfpe, so don't set this bit in QEMU either.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Peter Maydell
43ce393ee5 linux-user/elfload.c: Fix incorrect ARM HWCAP bits
The ELF HWCAP bits for ARM features THUMBEE, NEON, VFPv3 and VFPv3D16 are
all off by one compared to the kernel definitions. Fix this discrepancy
and add in the missing CRUNCH bit which was the cause of the off-by-one
error. (We don't emulate any of the CPUs which have that weird hardware,
so it's otherwise uninteresting to us.)

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Riku Voipio
e586822a58 linux-user: remove configure option for setting uname release
--enable-uname-release was a rather heavyweight hammer, as it allows
providing values less that UNAME_MINIMUM_RELEASE. Also, it affects
all built linux-user targets, which in most cases is not what user
wants.

Now that we have UNAME_MINIMUM_RELEASE for all linux-user platforms,
we can drop --enable-uname-release and the related CONFIG_UNAME_RELEASE
define.

Users can still override the variable with QEMU_UNAME=2.6.32 or -r
command line option. If distributors need to update a minimum version
for a specific target, it can be done by updating UNAME_MINIMUM_RELEASE.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Riku Voipio
6d30db19ca linux-user: move uname functions to uname.c
Make syscall.c slightly smaller by moving uname-related
functions to uname.c.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Riku Voipio
18cb008865 linux-user: rename cpu-uname -> uname
To move more uname related functions out of syscall.c,
rename cpu-uname.{c,h} to uname.{c.h}

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Peter Maydell
7af03928b1 linux-user/signal.c: Set fault address in AArch64 signal info
Set the fault address correctly in the signal information passed
to a signal handler for AArch64 guests.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:36 +03:00
Natanael Copa
34d6086236 linux-user: avoid using glibc internals in _syscall5 and in definition of target_sigevent struct
Use the public sigset_t instead of the glibc specific internal
__sigset_t in _syscall.

Calculate the sigevent pad size is calculated in similar way as kernel
does it instead of using glibc internal field _pad.

This is needed for building with musl libc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-02 21:59:28 +03:00
James Hogan
a29e5ba21f linux-user: Handle arches with llseek instead of _llseek
Recently merged kernel ports (such as OpenRISC and Meta) have an llseek
system call instead of _llseek. This is handled for the host
architecture by defining __NR__llseek as __NR_llseek, but not for the
target architecture.

Handle it in the same way for these architectures, defining
TARGET_NR__llseek as TARGET_NR_llseek.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Jia Liu <proljc@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:28 +03:00
Huw Davies
4bc2975698 linux-user: Add support for SCM_CREDENTIALS.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:28 +03:00
Huw Davies
52b6549442 linux-user: Move if-elses to a switch statement.
This makes adding more message types cleaner.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:27 +03:00
James Hogan
8c0f0a60d4 linux-user: Assert stack used for auxvec, envp, argv
Assert that the amount of stack space used for auxvec, envp & argv
exactly matches the amount allocated. This catches if DLINFO_ITEMS isn't
updated when another NEW_AUX_ENT is added.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:27 +03:00
Maxim Ostapenko
aa07f5ecf9 linux-user: Add /proc/self/exe open forwarding
QEMU already supports /proc/self/{maps,stat,auxv} so addition of
/proc/self/exe is rather trivial.

Fixes https://bugs.launchpad.net/qemu/+bug/1299190

Signed-off-by: Maxim Ostapenko <m.ostapenko@partner.samsung.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2014-05-02 21:59:27 +03:00
Peter Maydell
fdaad4715a Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20140501' into staging
target-arm queue:
 * implement XScale cache lockdown cp15 ops
 * fix v7M CPUID base register
 * implement WFE and YIELD as yields for A64
 * fix A64 "BLR LR"
 * support Cortex-A57 in virt machine model
 * a few other minor AArch64 bugfixes

# gpg: Signature made Thu 01 May 2014 15:42:17 BST using RSA key ID 14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"

* remotes/pmaydell/tags/pull-target-arm-20140501:
  hw/arm/virt: Add support for Cortex-A57
  hw/arm/virt: Put GIC register banks on 64K boundaries
  hw/arm/virt: Create the GIC ourselves rather than (ab)using a15mpcore_priv
  target-arm: Correct a comment refering to EL0
  target-arm: A64: Fix a typo when declaring TLBI ops
  target-arm: A64: Handle blr lr
  target-arm: Make vbar_write 64bit friendly on 32bit hosts
  target-arm: implement WFE/YIELD as a yield for AArch64
  armv7m_nvic: fix CPUID Base Register
  target-arm: Implement XScale cache lockdown operations as NOPs

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-02 11:32:00 +01:00
Peter Maydell
e50bf23438 Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches

# gpg: Signature made Wed 30 Apr 2014 19:19:32 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream: (31 commits)
  curl: Fix hang reading from slow connections
  curl: Ensure all informationals are checked for completion
  curl: Eliminate unnecessary use of curl_multi_socket_all
  curl: Remove unnecessary explicit calls to internal event handler
  curl: Remove erroneous sleep waiting for curl completion
  curl: Fix return from curl_read_cb with invalid state
  curl: Remove unnecessary use of goto
  curl: Fix long line
  block/vdi: Error out immediately in vdi_create()
  block/bochs: Fix error handling for seek_to_sector()
  qcow2: Check min_size in qcow2_grow_l1_table()
  qcow2: Catch bdrv_getlength() error
  block: Use correct width in format strings
  qcow2: Avoid overflow in alloc_clusters_noref()
  block: Use error_abort in bdrv_image_info_specific_dump()
  block: Fix open_flags in bdrv_reopen()
  Revert "block: another bdrv_append fix"
  block: Unlink temporary files in raw-posix/win32
  block: Remove BDRV_O_COPY_ON_READ for bs->file
  block: Create bdrv_backing_flags()
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-02 10:50:58 +01:00
Peter Maydell
c090c10dc4 Merge remote-tracking branch 'remotes/cohuck/tags/kvm_cap_helpers' into staging
Add helpers for enabling kvm capabilities and convert the existing
s390x and ppc users to use them.

# gpg: Signature made Wed 30 Apr 2014 14:48:45 BST using RSA key ID C6F02FAF
# gpg: Can't check signature: public key not found

* remotes/cohuck/tags/kvm_cap_helpers:
  ppc: use kvm_vcpu_enable_cap()
  s390x: use kvm_vcpu_enable_cap()
  kvm: add kvm_{vm,vcpu}_enable_cap

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 17:32:25 +01:00
Peter Maydell
87f6ede9bb Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-2' into staging
vga: add secondary stdvga variant

# gpg: Signature made Mon 28 Apr 2014 10:11:44 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-vga-2:
  add secondary-vga to display-vga test
  add display-vga test
  vga: add secondary stdvga variant
  vga: allow non-global vmstate

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 16:02:45 +01:00
Peter Maydell
f42c5c8ec8 hw/arm/virt: Add support for Cortex-A57
Support the Cortex-A57 in the virt machine model.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1398362083-17737-4-git-send-email-peter.maydell@linaro.org
2014-05-01 15:25:52 +01:00
Peter Maydell
3078e848fa hw/arm/virt: Put GIC register banks on 64K boundaries
For an AArch64 CPU which supports 64K pages, having the GIC
register banks at 4K offsets is potentially awkward. Move
them out to being at 64K offsets. (This is harmless for
AArch32 CPUs and for AArch64 CPUs with 4K pages, so it is simpler
to use the same offsets everywhere than to try to use 64K offsets
only for AArch64 host CPUs.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1398362083-17737-3-git-send-email-peter.maydell@linaro.org
2014-05-01 15:25:52 +01:00
Peter Maydell
6420474384 hw/arm/virt: Create the GIC ourselves rather than (ab)using a15mpcore_priv
Rather than having the virt machine model create an a15mpcore_priv
device regardless of the actual CPU type in order to instantiate the GIC,
move to having the machine model create the GIC directly. This
corresponds to a system which uses a standalone GIC (eg the GIC-400)
rather than the one built in to the CPU core.

The primary motivation for this is to support the Cortex-A57,
which for a KVM configuration will use a GICv2, which is not
built into the CPU.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1398362083-17737-2-git-send-email-peter.maydell@linaro.org
2014-05-01 15:24:46 +01:00
Edgar E. Iglesias
37f0806ed9 target-arm: Correct a comment refering to EL0
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1398926097-28097-5-git-send-email-edgar.iglesias@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 15:24:46 +01:00
Edgar E. Iglesias
6ab9f49934 target-arm: A64: Fix a typo when declaring TLBI ops
Harmless typo as opc1 defaults to zero and opc2 gets
re-declared to its correct value.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1398926097-28097-4-git-send-email-edgar.iglesias@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 15:24:46 +01:00
Edgar E. Iglesias
1b505f93bc target-arm: A64: Handle blr lr
For linked branches, updates to the link register happen
conceptually after the read of the branch target register.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Cc: qemu-stable@nongnu.org
Message-id: 1398926097-28097-3-git-send-email-edgar.iglesias@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 15:24:45 +01:00
Edgar E. Iglesias
fed3ffb9f1 target-arm: Make vbar_write 64bit friendly on 32bit hosts
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1398926097-28097-2-git-send-email-edgar.iglesias@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 15:24:45 +01:00
Rob Herring
252ec40576 target-arm: implement WFE/YIELD as a yield for AArch64
Like was done for AArch32 for WFE, implement both WFE and YIELD as a
yield operation. This speeds up multi-core system emulation.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
Message-id: 1397588401-20366-1-git-send-email-robherring2@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 15:24:45 +01:00
Rabin Vincent
e3da9921eb armv7m_nvic: fix CPUID Base Register
cp15.c0_cpuid is never initialized for ARMv7-M; take the value directly
from cpu->midr instead.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Message-id: 1398036308-32166-1-git-send-email-rabin@rab.in
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 15:24:44 +01:00
Peter Maydell
3b77157964 target-arm: Implement XScale cache lockdown operations as NOPs
XScale defines some implementation-specific coprocessor registers
for doing cache lockdown operations. Since QEMU doesn't model a
cache no proper implementation is possible, but NOP out the
registers so that guest code like u-boot that tries to use them
doesn't crash.

Reported-by: <prqek@centrum.cz>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 15:24:44 +01:00
Peter Maydell
051b9980b9 Merge remote-tracking branch 'remotes/kraxel/tags/pull-gtk-6' into staging
gtk: collection of fixes and cleanups by Cole Robinson

# gpg: Signature made Tue 29 Apr 2014 10:44:44 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-gtk-6:
  gtk: Fix accelerators being triggered twice with gtk3
  gtk: Fix -serial vc
  gtk: Use ctrl+alt+q for quit accelerator
  gtk: Remove use of deprecated stock items
  gtk: Don't use deprecated vte_terminal_get_adjustment
  gtk: Don't use deprecated gtk_image_menu_item_new_with_mnemonic
  configure: Re-run make if gtkabi/sdlabi is changed
  configure: Document --with-gtkabi

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 14:17:33 +01:00
Peter Maydell
52b08670e2 Merge remote-tracking branch 'remotes/kraxel/tags/pull-sdl-2' into staging
sdl2: mouse wheel support, ui config notify

# gpg: Signature made Tue 29 Apr 2014 11:17:01 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-sdl-2:
  sdl2: Support mouse wheel
  sdl2: add ui info setting.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 13:51:23 +01:00
Peter Maydell
61e5b75c17 Merge remote-tracking branch 'remotes/kraxel/tags/pull-audio-4' into staging
hda-audio: fix non-mixer codecs

# gpg: Signature made Tue 29 Apr 2014 10:03:44 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-audio-4:
  hda-audio: fix non-mixer codecs

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-01 13:05:54 +01:00
Matthew Booth
b7079df410 curl: Fix hang reading from slow connections
When receiving a new aio read request, we first look for an existing
transaction whose range will cover the read request by the time it
completes. However, we weren't checking that the existing transaction
was still active. If it had timed out, we were adding the request to a
transaction which would never complete and had already been cancelled,
resulting in a hang.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:34:21 +02:00
Matthew Booth
1f2cead324 curl: Ensure all informationals are checked for completion
According to the documentation, the correct way to ensure all
informationals have been returned by curl_multi_info_read is to loop
until it returns NULL.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:34:18 +02:00
Matthew Booth
838ef60249 curl: Eliminate unnecessary use of curl_multi_socket_all
curl_multi_socket_all is a deprecated catch-all which checks for
activities on all open curl sockets. We have enough information from
the event loop to check only the sockets with activity. This change
removes use of curl_multi_socket_all in favour of
curl_multi_socket_action called with the relevant handle.

At the same time, it also ensures that the driver only checks for
completion of read operations after reading from a socket, rather than
both reading and writing.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:34:16 +02:00
Matthew Booth
b69cdef876 curl: Remove unnecessary explicit calls to internal event handler
Remove calls to curl_multi_do where the relevant handles are already
registered to the event loop.

Ensure that we kick off socket handling with CURL_SOCKET_TIMEOUT after
adding a new handle.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:34:14 +02:00
Matthew Booth
e466183718 curl: Remove erroneous sleep waiting for curl completion
The driver will not start more than a fixed number of curl sessions.
If it needs more, it must wait for the completion of an existing one.
The driver was sleeping, which will prevent the main loop from
running, and therefore the event it's waiting on. It was also directly
calling its internal handler rather than waiting on existing
registered handlers to be called from the main loop.

This change causes it simply to wait for a period of time whilst
allowing the main loop to execute.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:34:11 +02:00
Matthew Booth
38bbc0a580 curl: Fix return from curl_read_cb with invalid state
A curl write callback is supposed to return the number of bytes it
handled.  curl_read_cb would have erroneously reported it had handled
all bytes in the event that the internal curl state was invalid.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:34:08 +02:00
Matthew Booth
9e550b3260 curl: Remove unnecessary use of goto
This isn't any of the usually acceptable uses of goto.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:34:06 +02:00
Matthew Booth
f6246509be curl: Fix long line
Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 16:33:39 +02:00
Max Reitz
0549ea8b6d block/vdi: Error out immediately in vdi_create()
Currently, if an error occurs during the part of vdi_create() which
actually writes the image, the function stores -errno, but continues
anyway.

Instead of trying to write data which (if it can be written at all) does
not make any sense without the operations before succeeding (e.g.,
writing the image header), just error out immediately.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 14:46:17 +02:00
Max Reitz
e1b42f456f block/bochs: Fix error handling for seek_to_sector()
Currently, seek_to_sector() returns -1 both for errors and unallocated
sectors, resulting in silent errors. As 0 is an invalid offset of data
clusters (bitmap_offset is greater than 0 because s->data_offset is
greater than 0), just return 0 for unallocated sectors and -errno in
case of error. This should then be propagated by bochs_read(), the sole
user of seek_to_sector().

That function also has a case of "return -1 in case of error", which is
fixed by this patch as well.

bochs_read() is called by bochs_co_read() which passes the return value
through, therefore it is indeed correct for bochs_read() to return
-errno.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 14:46:17 +02:00
Max Reitz
b93f995081 qcow2: Check min_size in qcow2_grow_l1_table()
First, new_l1_size is an int64_t, whereas min_size is a uint64_t.
Therefore, during the loop which adjusts new_l1_size until it equals or
exceeds min_size, new_l1_size might overflow and become negative. The
comparison in the loop condition however will take it as an unsigned
value (because min_size is unsigned) and therefore recognize it as
exceeding min_size. Therefore, the loop is left with a negative
new_l1_size, which is not correct. This could be fixed by making
new_l1_size uint64_t.

On the other hand, however, by doing this, the while loop may take
forever. If min_size is e.g. UINT64_MAX, it will take new_l1_size
probably multiple overflows to reach the exact same value (if it reaches
it at all). Then, right after the loop, new_l1_size will be recognized
as being too big anyway.

Both problems require a ridiculously high min_size value, which is very
unlikely to occur; but both problems are also simply avoided by checking
whether min_size is sane before calculating new_l1_size (which should
still be checked separately, though).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 14:46:17 +02:00
Max Reitz
a49139af77 qcow2: Catch bdrv_getlength() error
The call to bdrv_getlength() from qcow2_check_refcounts() may result in
an error. Check this and abort if necessary.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 14:46:17 +02:00
Max Reitz
521b2b5df0 block: Use correct width in format strings
Instead of blindly relying on a normal integer having a width of 32 bits
(which is a pretty good assumption, but we should not rely on it if
there is no need), use the correct format string macros.

This does not touch DEBUG output.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 14:46:17 +02:00
Max Reitz
91f827dcff qcow2: Avoid overflow in alloc_clusters_noref()
alloc_clusters_noref() stores the cluster index in a uint64_t. However,
offsets are often represented as int64_t (as for example the return
value of alloc_clusters_noref() itself demonstrates). Therefore, we
should make sure all offsets in the allocated range of clusters are
representable using int64_t without overflows.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 14:46:13 +02:00
Cornelia Huck
48add816cf ppc: use kvm_vcpu_enable_cap()
Convert existing users of KVM_ENABLE_CAP to new helper.

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-04-30 14:39:58 +02:00
Cornelia Huck
e080f0fdff s390x: use kvm_vcpu_enable_cap()
Make kvm_s390_enable_css_support() use new interface.

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-04-30 14:39:49 +02:00
Cornelia Huck
40f1ee27aa kvm: add kvm_{vm,vcpu}_enable_cap
Provide helper functions for enabling capabilities (on a vcpu and on a vm).

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-04-30 14:39:39 +02:00
Max Reitz
35d0d40a03 block: Use error_abort in bdrv_image_info_specific_dump()
Currently, bdrv_image_info_specific_dump() uses an error variable for
visit_type_ImageInfoSpecific, but ignores the result. As this function
is used here with an output visitor to transform the ImageInfoSpecific
object to a generic QDict, an error should actually be impossible. It is
however better to assert that this is indeed the case. This is done by
this patch using error_abort instead of an unused local Error variable.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-30 12:43:30 +02:00
Kevin Wolf
f1f25a2e2e block: Fix open_flags in bdrv_reopen()
Use the same function as bdrv_open() for determining what the right
flags for bs->file are. Without doing this, a reopen means that
bs->file loses BDRV_O_CACHE_WB or BDRV_O_UNMAP if bs doesn't have it as
well.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-30 11:05:00 +02:00
Kevin Wolf
7e3d98dd31 Revert "block: another bdrv_append fix"
This reverts commit 3a389e7926. The commit
was wrong and what it tried to fix just works today without any change.

What the commit tried to fix:

    When creating live snapshots, the new image file is opened with
    BDRV_O_NO_BACKING because the whole backing chain is already opened.
    It is then appended to the chain using bdrv_append(). The result of
    this was that the image had a backing file, but BDRV_O_NO_BACKING
    was still set. This is obviously inconsistent.

    There used to be some places in qemu that closed and image and then
    opened it again, with its old flags (a bdrv_open()/close() sequence
    involves reopening the whole backing file chain, too). In this case
    the BDRV_O_NO_BACKING flag meant that the backing chain wasn't
    reopened and only the top layer was left.

    (Most, but not all of these places are replaced by bdrv_reopen()
    today, which doesn't touch the backing files at all.)

    Other places that looked at bs->open_flags weren't interested in
    BDRV_O_NO_BACKING, so no breakage there.

What it actually did:

    The commit moved the BDRV_O_NO_BACKING away to the backing file.
    Because the bdrv_open()/close() sequences only looked at the flags
    of the top level BlockDriverState and used it for the whole chain,
    the flag didn't hurt there any more. Obviously, it is still
    inconsistent because the backing file may have another backing file,
    but without practical impact.

    At the same time, it swapped all other flags. This is practically
    irrelevant as long as live snapshots only allow opening the new
    layer with the same flags as the old top layer. It still doesn't
    make any sense, and it is a time bomb that explodes as soon as the
    flags can differ.

    bdrv_append_temp_snapshot() is such a case: It adds the new flag
    BDRV_O_TEMPORARY for the temporary snapshot. The swapping of commit
    3a389e79 results in the following nonsensical configuration:

    bs->open_flags:                     BDRV_O_TEMPORARY cleared
    bs->file->open_flags:               BDRV_O_TEMPORARY set
    bs->backing_hd->open_flags:         BDRV_O_TEMPORARY set
    bs->backing_hd->file->open_flags:   BDRV_O_TEMPORARY cleared

    We're still lucky because the format layer ignores the flag and the
    protocol layer happens to get the right value, but sooner or later
    this is bound to go wrong...

What the right fix would have been:

    Simply clear the BDRV_O_NO_BACKING flag when the BlockDriverState is
    appended to an existing backing file chain, because now it does have
    a backing file.

    Commit 4ddc07ca already implemented this silently in bdrv_append(),
    so we don't have to come up with a new fix.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-30 11:05:00 +02:00
Kevin Wolf
8bfea15dda block: Unlink temporary files in raw-posix/win32
Instead of having unlink() calls in the generic block layer, where we
aren't even guarateed to have a file name, move them to those block
drivers that are actually used and that always have a filename. Gets us
rid of some #ifdefs as well.

The patch also converts bs->is_temporary to a new BDRV_O_TEMPORARY open
flag so that it is inherited in the protocol layer and the raw-posix and
raw-win32 drivers can unlink the file.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-30 11:05:00 +02:00
Kevin Wolf
5669b44de5 block: Remove BDRV_O_COPY_ON_READ for bs->file
Copy on Read makes sense on the format level where backing files are
implemented, but it's not required on the protocol level. While it
shouldn't actively break anything to have COR enabled on both layers,
needless serialisation and allocation checks may impact performance.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-30 11:05:00 +02:00
Kevin Wolf
317fc44ef2 block: Create bdrv_backing_flags()
Instead of manipulation flags inline, move the derivation of the flags
of a backing file into a new function next to the existing functions
that derive flags for bs->file and for the block driver open function.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-30 11:05:00 +02:00
Kevin Wolf
0b50cc8853 block: Create bdrv_inherited_flags()
Instead of having bdrv_open_flags() as a function that creates flags for
several unrelated places and then adding open-coded flags on top, create
a new function that derives the flags for bs->file from the flags for bs.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-30 11:05:00 +02:00
Max Reitz
cffb12051a iotests: Discarding compressed clusters on qcow2
Add a test which discards a compressed cluster on qcow2. This should
work without any problems.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 16:39:51 +02:00
Max Reitz
c883db0df9 qcow2: Fix discard
discard_single_l2() should not implement its own version of
qcow2_get_cluster_type(), but rather rely on this already existing
function. By doing so, it will work for compressed clusters as well
(which it did not so far).

Also, rename "old_offset" to "old_l2_entry", as both are quite different
(and the value is indeed of the latter kind).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 16:39:51 +02:00
Jeff Cody
cc8a7e560c block: qemu-iotests: make test 019 and 086 work with spaced pathnames
Both tests 019 and 086 need proper quotations to work with pathnames
that contain spaces.

Reviewed-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 16:19:37 +02:00
Jeff Cody
c557527455 block: qemu-iotests - fix image cleanup when using spaced pathnames
The _rm_test_img() function in common.rc did not quote the image
file, which left droppings in the scratch directory (and performed
a potentially unsafe rm -f).

This adds the necessary quotes.

Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 16:19:33 +02:00
Peter Maydell
b006f8162e Merge remote-tracking branch 'remotes/rth/tags/tcg-sparc-pull-20140428' into staging
TCG sparc backend update for 20140428

# gpg: Signature made Mon 28 Apr 2014 19:36:55 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/tcg-sparc-pull-20140428:
  tcg-sparc: Accept stores of zero
  tcg-sparc: Fix small 32-bit movi
  tcg-sparc: Fixup function argument types
  tcg-sparc: Hoist common argument loads in tcg_out_op
  tcg-sparc: Don't handle mov/movi in tcg_out_op
  tcg-sparc: Tidy check_fit_* tests
  tcg-sparc: Implement muls2_i32
  tcg-sparc: Use the RETURN instruction
  tcg-sparc: Use 64-bit registers with sparcv8plus
  tcg-sparc: Support trunc_shr_i32
  tcg-sparc: Remove most uses of TCG_TARGET_REG_BITS
  tcg: Add INDEX_op_trunc_shr_i32
  tcg: Fix missed pointer size != TCG_TARGET_REG_BITS changes

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-29 13:03:25 +01:00
Fam Zheng
c3cc95bd15 mirror: Check for bdrv_get_info result
bdrv_get_info could fail. Add check before using the returned value.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 13:43:08 +02:00
Fam Zheng
373df5b135 mirror: Fix resource leak when bdrv_getlength fails
The direct return will skip releasing of all the resouces at
immediate_exit, don't miss that.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 13:43:00 +02:00
Jeff Cody
e855e4fb7b block: Ignore duplicate or NULL format_name in bdrv_iterate_format
Some block drivers have multiple BlockDriver instances with identical
format_name fields (e.g. gluster, nbd).

Both qemu-img and qemu will use bdrv_iterate_format() to list the
supported formats when a help option is invoked.  As protocols and
formats may register multiple drivers, redundant listings of formats
occur (e.g., "Supported formats: ... gluster gluster gluster gluster ...
").

Since the list of driver formats will be small, this performs a simple
linear search on format_name, and ignores any duplicates.

The end result change is that the iterator will no longer receive
duplicate string names, nor will it receive NULL pointers.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 11:58:07 +02:00
Cole Robinson
3f2fde2a00 sdl2: Support mouse wheel
In SDL2, wheel movement is its own event, not a button event. Wire
it up similar to gtk.c

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:33 +02:00
Dave Airlie
8b15d9f1d2 sdl2: add ui info setting.
Allows you to resize the sdl2 window and have the guest notice.

[ kraxel: zero-initialize QemuUIInfo ]

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:33 +02:00
Cole Robinson
341a034742 gtk: Fix accelerators being triggered twice with gtk3
When keyboard focus is grabbed, current qemu wants to pass every
keypress to the VM, unless the user is pressing a UI accelerator.

That's exactly how things work without any of the fancy handling. Drop
the special handling, which seems to trigger accelerators twice on gtk3.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Cole Robinson
d437074140 gtk: Fix -serial vc
Try kicking off a rhel5 text install over serial, the text menu navigation
is all messed up, and some of the kernel boot messages are randomly
corrupted.

Drop use of a pty and just use vte infrastructure for reading and writing.
This fixes the above corruption, and is simpler to boot.

(I don't know what was wrong with the original code though. FWIW this is
what virt-manager has done for years).

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Cole Robinson
db1da1f2b5 gtk: Use ctrl+alt+q for quit accelerator
Using the standard ctrl+q makes it too easy to kill the whole VM. Using
ctrl+alt+FOO is consistent with our other accelerators.

https://bugzilla.redhat.com/show_bug.cgi?id=1062393
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Cole Robinson
3d914488ae gtk: Remove use of deprecated stock items
Stock items are deprecated. As are ImageMenuItems. Convert everything to
text only MenuItems, with the same text content as mentioned in the
conversion guide:

https://docs.google.com/spreadsheet/pub?key=0AsPAM3pPwxagdGF4THNMMUpjUW5xMXZfdUNzMXhEa2c&output=html

gtk2 users lose their menu icons as well, but I don't think that's enough
of a problem to warrant keeping around back compat code.

Example error:

ui/gtk.c:1328:5: error: ‘GtkStock’ is deprecated [-Werror=deprecated-declarations]
ui/gtk.c:1335:5: error: ‘gtk_image_menu_item_new_from_stock’ is deprecated (declared at /usr/include/gtk-3.0/gtk/deprecated/gtkimagemenuitem.h:78): Use 'gtk_menu_item_new' instead [-Werror=deprecated-declarations]
     s->zoom_out_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Cole Robinson
105923e08c gtk: Don't use deprecated vte_terminal_get_adjustment
Guard this with a VTE version check, since I'm not sure if this is backwards
compatible.

ui/gtk.c: In function ‘gd_vc_init’:
ui/gtk.c:1176:5: error: ‘vte_terminal_get_adjustment’ is deprecated (declared at /usr/include/vte-2.90/vte/vtedeprecated.h:101) [-Werror=deprecated-declarations]

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Cole Robinson
9068f20dfb gtk: Don't use deprecated gtk_image_menu_item_new_with_mnemonic
In these cases we weren't using an image in the menu item anyways, so
just do as the suggestion says. Should be fine for all qemu supported
gtk versions.

ui/gtk.c: In function ‘gd_create_menu_machine’:
ui/gtk.c:1284:5: error: ‘gtk_image_menu_item_new_with_mnemonic’ is deprecated (declared at /usr/include/gtk-3.0/gtk/deprecated/gtkimagemenuitem.h:76): Use 'gtk_menu_item_new_with_mnemonic' instead [-Werror=deprecated-declarations]
     s->reset_item = gtk_image_menu_item_new_with_mnemonic(_("_Reset"));
     ^
ui/gtk.c:1287:5: error: ‘gtk_image_menu_item_new_with_mnemonic’ is deprecated (declared at /usr/include/gtk-3.0/gtk/deprecated/gtkimagemenuitem.h:76): Use 'gtk_menu_item_new_with_mnemonic' instead [-Werror=deprecated-declarations]
     s->powerdown_item = gtk_image_menu_item_new_with_mnemonic(_("Power _Down"));

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Cole Robinson
a3f4d63d63 configure: Re-run make if gtkabi/sdlabi is changed
Reconfiguring with a different --with-gtkabi or --with-sdlabi doesn't
trigger a remake. Generate an (unused) CONFIG_GTKABI/CONFIG_SDLABI
so config-host.h will actually give 'make' something to trigger on.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Cole Robinson
f92d61f336 configure: Document --with-gtkabi
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:30 +02:00
Gerd Hoffmann
4843877e5d hda-audio: fix non-mixer codecs
They don't advertise mixer support, but still allow the guest change
mixer settings.  Add a check to avoid it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29 10:46:29 +02:00
Jeff Cody
5f6979cba9 block: Add '--version' option to qemu-img
This allows qemu-img to print out version information, without
needing to print the long help wall of text.

While there, perform some minor whitespace cleanup, and remove the
unused option_index variable in the call to getopt_long().

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-29 10:36:35 +02:00
Richard Henderson
ebd0c614d7 tcg-sparc: Accept stores of zero
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
035b239826 tcg-sparc: Fix small 32-bit movi
We tested imm13 before discarding garbage high bits.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
35e2da1556 tcg-sparc: Fixup function argument types
Use TCGReg everywhere appropriate.  Use int32_t for all arguments
that may be registers or immediate constants.  Merge tcg_out_addi
into its only caller.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
b357f902bf tcg-sparc: Hoist common argument loads in tcg_out_op
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
98b90bab3f tcg-sparc: Don't handle mov/movi in tcg_out_op
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
425532d71d tcg-sparc: Tidy check_fit_* tests
Use sextract instead of raw bit shifting for the tests.  Introduce
a new check_fit_ptr macro to make it clear we're looking at pointers.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
f4c166619e tcg-sparc: Implement muls2_i32
Using the 32-bit SMUL is a tad more efficient than
resorting to extending and using the 64-bit MULX.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
8b66eefe0d tcg-sparc: Use the RETURN instruction
Saves one insn per TB exit over JMPL+RESTORE.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
34b1a49cb1 tcg-sparc: Use 64-bit registers with sparcv8plus
Quite a lot of effort was spent composing and decomposing 64-bit
quantities in registers, when we should just create them and leave
them as one 64-bit register.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
a24fba935a tcg-sparc: Support trunc_shr_i32
Unlike a 64-bit shift op, allows the output to be in %l or %i registers
for sparcv8plus.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
9f44adc573 tcg-sparc: Remove most uses of TCG_TARGET_REG_BITS
Replace with SPARC64 define.  Soon even sparcv8plus will use
64-bit register as far as TCG is concerned.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:35 -07:00
Richard Henderson
4bb7a41ed6 tcg: Add INDEX_op_trunc_shr_i32
Let the backend do something special for truncation.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:34 -07:00
Richard Henderson
71b926992e tcg: Fix missed pointer size != TCG_TARGET_REG_BITS changes
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-28 11:06:34 -07:00
Fam Zheng
f0e9736012 mirror: Use DIV_ROUND_UP
Although bdrv_getlength() was just called above this, and checked for
error, it is better to just use the value we already get, and use
DIV_ROUND_UP.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-28 17:36:30 +02:00
Jeff Cody
7db1689c35 block: fix qemu-img --help invocation
This fixes a bug introduced in commit ac1307ab, that caused the
'--help' option to not be recognized as a valid command, and not
print any help.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-28 17:36:30 +02:00
Peter Maydell
e2da502c00 Merge remote-tracking branch 'remotes/otubo/seccomp' into staging
* remotes/otubo/seccomp:
  seccomp: add shmctl(), mlock(), and munlock() to the syscall whitelist
  seccomp: add timerfd_create and timerfd_settime to the whitelist

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-28 14:14:35 +01:00
Peter Maydell
93156cef1c Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-04-28' into staging
trivial patches for 2014-04-28

# gpg: Signature made Mon 28 Apr 2014 05:56:01 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
#      Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514  66A7 BEE5 9D74 A4C3 D7DB

* remotes/mjt/tags/trivial-patches-2014-04-28:
  slirp/smb: Move ncalrpc directory to tmp
  po: add proper Language: tags to .po files
  po/Makefile: fix $SRC_PATH reference
  init_paths: fix minor memory leak
  virtfs-proxy-helper: fix call to accept
  net/net.c: remove unnecessary semicolon
  Add QEMU logo (SVG file)
  vl: avoid closing stdout with 'writeconfig'
  xilinx: Fix typo in comment (Marvel -> Marvell)
  vl: Eliminate a superfluous local variable
  vl: Remove useless 'continue'
  gitignore: cleanups #2
  tests/.gitignore: Ignore test-rfifolock
  move test-* from .gitignore to tests/.gitignore
  configure: Improve help behavior
  vl: convert -m to QemuOpts
  qemu-option: introduce qemu_find_opts_singleton
  misc: Use cpu_physical_memory_read and cpu_physical_memory_write

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-28 13:43:17 +01:00
Peter Maydell
13de54eedd Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp:
  monitor: fix qmp_getfd() fd leak in error case
  HMP: support specifying dump format for dump-guest-memory
  HMP: fix doc of dump-guest-memory
  qmp: object-add: Validate class before creating object
  monitor: Add device_add and device_del completion.
  monitor: Add command_completion callback to mon_cmd_t.
  monitor: Fix drive_del id argument type completion.
  error: Remove some unused headers
  qerror.h: Replace QERR_NOT_SUPPORTED with QERR_UNSUPPORTED
  qerror.h: Remove QERR defines that are only used once
  qerror.h: Remove unused error classes
  error: Print error_report() to stderr if using qmp
  monitor: Remove unused monitor_print_filename
  error: Privatize error_print_loc
  vnc: Remove default_mon usage
  slirp: Remove default_mon usage

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-28 12:56:34 +01:00
Peter Maydell
a41b2c995b Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request

# gpg: Signature made Fri 25 Apr 2014 17:05:13 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  iscsi: Don't use error_is_set() to suppress additional errors
  blockdev: Clean up fragile use of error_is_set()
  nbd: Use return values instead of error_is_set(errp)
  qemu-img: Consistently name Error * objects err, and not errp
  Use error_is_set() only when necessary (again)
  block: Expose host_* drivers in blockdev-add
  MAINTAINERS: Add qemu-img/io to block subsystem
  qemu-iotests: Improve and make use of QMPTestCase.wait_until_completed()
  doc: add -drive rerror=,werror= to qemu --help output
  block: Prevent coroutine stack overflow when recursing in bdrv_open_backing_file.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-28 11:50:31 +01:00
Peter Maydell
d09a18d44d Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging
Net patches

# gpg: Signature made Fri 25 Apr 2014 15:07:31 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/net-pull-request:
  net: Don't use error_is_set() to suppress additional errors
  net: Make qmp_query_rx_filter() with name argument more obvious
  net: xilinx_axienet.c: Add phy soft reset bit clearing
  net/net.c: Remove unnecessary semicolon
  pcnet: remove duplicate assignment
  tap: Avoid extra iterations while closing file fd

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-28 11:29:03 +01:00
Peter Maydell
4a39cbb034 Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20140425' into staging
Some s390x patches:

- gdb stubs to make it compile if gdb support is pulled in
- linux-headers update for new oneregs
- two onereg enhancements

# gpg: Signature made Fri 25 Apr 2014 12:42:46 BST using RSA key ID C6F02FAF
# gpg: Can't check signature: public key not found

* remotes/cohuck/tags/s390x-20140425:
  s390x/kvm: sync gbea and pp register
  s390x/kvm: rework KVM synchronize to tracing for some ONEREGS
  linux-headers update
  s390x: empty function stubs in preparation for __KVM_HAVE_GUEST_DEBUG

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-28 10:51:32 +01:00
Gerd Hoffmann
a889bc2bb2 add secondary-vga to display-vga test
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-28 11:03:39 +02:00
Gerd Hoffmann
0850fd583f add display-vga test
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-28 11:03:35 +02:00
Gerd Hoffmann
63e3e24db2 vga: add secondary stdvga variant
Add a standard vga variant which doesn't occupy any legacy
resources and thus can easily be used as secondary (or legacy-free)
graphics adapter.  Programming must be done using the MMIO bar.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-28 11:03:32 +02:00
Gerd Hoffmann
e2bbfc8ee2 vga: allow non-global vmstate
Need a way to opt-out from vga.vram being global vmstate, for
secondary vga cards.  Add a bool parameter to vga_common_init
to support this.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-28 10:21:55 +02:00
Michael Buesch
b87b8a8b32 slirp/smb: Move ncalrpc directory to tmp
The smbd forked by qemu still uses the default ncalrpc directory
in /var/run/samba. This may lead to problems, if /var/run/samba
does not exist (for example if /var/run is a tmpfs and the host
smbd was not started).

This leads to the following error message from samba
and an unworkable smbd:
	Failed to create pipe directory /var/run/samba/ncalrpc - No such file or directory

Fix this by pointing smbd to /tmp/qemu-smb.%d.%d/ncalrpc as ncalrpc directory.
Smbd will create the actual ncalrpc subdirectory on its own.

Signed-off-by: Michael Buesch <m@bues.ch>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Applying this to -trivial because it _is_ rather trivial
 and because Jan does not reply for months)
2014-04-28 08:55:32 +04:00
Michael Tokarev
7a30842186 po: add proper Language: tags to .po files
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:32 +04:00
Michael Tokarev
b920cad669 po/Makefile: fix $SRC_PATH reference
The rule for messages.po appears to be slightly wrong.
Move the `cd' command within parens.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Tested-by: Stefan Weil <sw@weilnetz.de>
2014-04-28 08:55:32 +04:00
Kirill Batuzov
00a9cacaea init_paths: fix minor memory leak
Fields "name" (created with strdup in new_entry) and "pathname"
(created with g_strdup_printf in new_entry) of pathelem struct should
be freed before the whole struct is.

Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:32 +04:00
Tim Comer
b0f9300ca3 virtfs-proxy-helper: fix call to accept
The current code calls accept() without initializing the size parameter
which means the accept call might write too much to the stack.

URL: https://bugs.gentoo.org/486714
Signed-off-by: Tim Comer <comer0@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:32 +04:00
Igor Ryzhov
9057698d93 net/net.c: remove unnecessary semicolon
Signed-off-by: Igor Ryzhov <iryzhov@arccn.ru>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:32 +04:00
Stefan Weil
d461863d3c Add QEMU logo (SVG file)
The "Q" of the logo is already included in pc-bios/qemu_logo_no_text.svg.

This file now adds the complete logo as it was designed by Benoît Canet.
Benoît licensed it under CC-BY 3.0, see
http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg02865.html.

Unneeded borders from Benoît's original logo were removed,
and metadata (license, author, date) was added in this version.

Cc: Benoît Canet <benoit@irqsave.net>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:31 +04:00
Chen Gang
7fb8b5d9c4 vl: avoid closing stdout with 'writeconfig'
'writeconfig' supports output to stdout (with '-'); when that happens,
we must not close stdout, or further command line options that also use
stdout will be impacted. (Although 'writeconfig' was copied from
'readconfig', the latter does not have the problem because it does not
support reading from '-')

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:31 +04:00
Stefan Weil
24c12b7923 xilinx: Fix typo in comment (Marvel -> Marvell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:31 +04:00
Chen Gang
6924bc1eef vl: Eliminate a superfluous local variable
CODING_STYLE frowns upon mixing declarations and statements.  main()
has such a declaration.  Clean up by eliminating the variable.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:31 +04:00
Chen Gang
a629f2fdba vl: Remove useless 'continue'
"This if else has no code between it and the end of the enclosing
while loop. This makes this continue redundant."

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:31 +04:00
Michael Tokarev
5d77c8f9b6 gitignore: cleanups #2
A few more cleanups for .gitignore file.
The final goal is to have only files in there which
are generated during build.  Things like .orig or
.gdbinit are definitely not generated during build.
Also, anchor a few more build-time directories.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-28 08:55:31 +04:00
Cole Robinson
a27b04577e tests/.gitignore: Ignore test-rfifolock
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-27 13:04:18 +04:00
Laszlo Ersek
296b14491a move test-* from .gitignore to tests/.gitignore
Also sort the test-* entries in the latter.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-27 13:04:18 +04:00
Fam Zheng
2d2ad6d090 configure: Improve help behavior
Old:
There are two paths to show help and exit 1, one is with "-h" or
"--help", one is with invalid options.

New:
Show help and exit 0 for --help.
On invalid option, don't show the long help and bury the early "ERROR:"
line, just give a message pointing to --help.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-27 13:04:18 +04:00
Igor Mammedov
6e1d3c1c85 vl: convert -m to QemuOpts
Adds option to -m
 "size" - startup memory amount

For compatibility with legacy CLI if suffix-less number is passed,
it assumes amount in Mb.

Otherwise user is free to use suffixed number using suffixes b,k/K,M,G

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-27 13:04:18 +04:00
Paolo Bonzini
e96e5ae880 qemu-option: introduce qemu_find_opts_singleton
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-27 13:04:18 +04:00
Stefan Weil
eb6282f230 misc: Use cpu_physical_memory_read and cpu_physical_memory_write
These functions don't need type casts (as does cpu_physical_memory_rw)
and also make the code better readable.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-27 13:04:18 +04:00
Paul Moore
e3f9bb011a seccomp: add shmctl(), mlock(), and munlock() to the syscall whitelist
Additional testing reveals that PulseAudio requires shmctl() and the
mlock()/munlock() syscalls on some systems/configurations.  As before,
on systems that do require these syscalls, the problem can be seen with
the following command line:

  # qemu -monitor stdio  -sandbox on \
         -device intel-hda -device hda-duplex

Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
2014-04-25 14:52:03 -03:00
Felix Geyer
8439761852 seccomp: add timerfd_create and timerfd_settime to the whitelist
libusb calls timerfd_create() and timerfd_settime() when it's built with
timerfd support.

Command to reproduce:

       -device usb-host,hostbus=1,hostaddr=3,id=hostdev0

Log messages:

audit(1390730418.924:135): auid=4294967295 uid=121 gid=103 ses=4294967295
                           pid=5232 comm="qemu-system-x86" sig=31 syscall=283
                           compat=0 ip=0x7f2b0f4e96a7 code=0x0
audit(1390733100.580:142): auid=4294967295 uid=121 gid=103 ses=4294967295
                           pid=16909 comm="qemu-system-x86" sig=31 syscall=286
                           compat=0 ip=0x7f03513a06da code=0x0

Reading a few hundred MB from a USB drive on x86_64 shows this syscall distribution.
Therefore the timerfd_settime priority is set to 242.

    calls  syscall
 --------- ----------------
   5303600 write
   2240554 read
   2167030 ppoll
   2134828 ioctl
    704023 timerfd_settime
    689105 poll
     83122 futex
       803 writev
       476 rt_sigprocmask
       287 recvmsg
       178 brk

Signed-off-by: Felix Geyer <debfx@fobos.de>
Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
2014-04-25 14:51:59 -03:00
Markus Armbruster
172fc4dd33 iscsi: Don't use error_is_set() to suppress additional errors
Using error_is_set(errp) that way can sweep programming errors under
the carpet when we get called incorrectly with an error set.

Commit 24d3bd6 added a broken error path to iscsi_do_inquiry(): it
first calls error_setg(), then jumps to the preexisting error label,
where error_setg() gets called again, triggering an assertion failure.

Commit cbee81f fixed this by guarding the second error_setg() with an
error_is_set().

Replace this fix by a simpler and safer one: jump right behind the
second error_setg().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:06 +02:00
Markus Armbruster
f70edf9948 blockdev: Clean up fragile use of error_is_set()
Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

The error_is_set(errp) in internal_snapshot_prepare() is merely
fragile, because the caller never passes a null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:06 +02:00
Markus Armbruster
92de901290 nbd: Use return values instead of error_is_set(errp)
Using error_is_set(errp) to check whether a function call failed is
fragile: it breaks when errp is null.  Check perfectly suitable return
values instead when possible.  errp can't be null there now, but this
is more robust and more obviously correct

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:06 +02:00
Markus Armbruster
4399c438a4 qemu-img: Consistently name Error * objects err, and not errp
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:06 +02:00
Markus Armbruster
0fb6395c0c Use error_is_set() only when necessary (again)
error_is_set(&var) is the same as var != NULL, but it takes
whole-program analysis to figure that out.  Unnecessarily hard for
optimizers, static checkers, and human readers.  Commit 84d18f0 dumbed
it down to obvious, but a few more have crept in since, and
documentation was overlooked.  Dumb these down, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:06 +02:00
Kevin Wolf
a28315ebaf block: Expose host_* drivers in blockdev-add
All the functionality to use the host_device, host_cdrom and host_floppy
drivers is already there, they just need to be added to the schema.

The block driver names containing underscores are preexisting and cannot
be changed without breaking command line compatibility.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:06 +02:00
Kevin Wolf
460787605e MAINTAINERS: Add qemu-img/io to block subsystem
qemu-img and qemu-io were not covered by any MAINTAINERS entry so far.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:05 +02:00
Fam Zheng
9974ad40bf qemu-iotests: Improve and make use of QMPTestCase.wait_until_completed()
This eliminates code duplication.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:05 +02:00
Stefan Hajnoczi
d1db760d7b doc: add -drive rerror=,werror= to qemu --help output
These options are already documented on the man page but missing from
qemu --help.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
2014-04-25 18:05:05 +02:00
Benoît Canet
1ba4b6a553 block: Prevent coroutine stack overflow when recursing in bdrv_open_backing_file.
In 1.7.1 qcow2_create2 reopen the file for flushing without the BDRV_O_NO_BACKING
flags.

As a consequence the code would recursively open the whole backing chain.

These three stack arrays would pile up through the recursion and lead to a coroutine
stack overflow.

Convert these array to malloced buffers in order to streamline the coroutine
footprint.

Symptoms where freezes or segfaults on production machines while taking QMP externals
snapshots. The overflow disturbed coroutine switching.

[Resolved conflicts on qemu.git/master since the patch was against v1.7.1
--Stefan]

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 18:05:05 +02:00
Stefan Hajnoczi
0b9f0e2fd7 monitor: fix qmp_getfd() fd leak in error case
qemu_chr_fe_get_msgfd() transfers ownership of the file descriptor to
the caller.  Therefore all code paths in qmp_getfd() should either
register the file descriptor somewhere or close it.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 11:41:41 -04:00
Qiao Nuohan
1b7a0f758b HMP: support specifying dump format for dump-guest-memory
Dumping guest memory is available to specify the dump format now. This patch
adds options '-z|-l|-s' to HMP command dump-guest-memory to specify dumping in
kdump-compression format, with zlib/lzo/snappy compression. And without these
options ELF format will be used.

The discussion about this feature is here:

http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg04235.html

Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Suggested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> (on s390x/kvm)
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 11:18:33 -04:00
Qiao Nuohan
c20499d985 HMP: fix doc of dump-guest-memory
Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 11:17:38 -04:00
Eduardo Habkost
c3481247e5 qmp: object-add: Validate class before creating object
Currently it is very easy to crash QEMU by issuing an object-add command
using an abstract class or a class that doesn't support
TYPE_USER_CREATABLE as parameter.

Example: with the following QMP command:

    (QEMU) object-add qom-type=cpu id=foo

QEMU aborts at:

    ERROR:qom/object.c:335:object_initialize_with_type: assertion failed: (type->abstract == false)

This patch moves the check for TYPE_USER_CREATABLE before object_new(),
and adds a check to prevent the code from trying to instantiate abstract
classes.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Tested-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 11:08:34 -04:00
Markus Armbruster
9083da1d4c net: Don't use error_is_set() to suppress additional errors
Using error_is_set(errp) that way can sweep programming errors under
the carpet when we get called incorrectly with an error set.

qmp_query_rx_filter() breaks its loop when it detects an error.  It
needs to set another error when the loop completes normally.

Return right away instead of merely breaking the loop.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 15:58:07 +02:00
Markus Armbruster
638fb14169 net: Make qmp_query_rx_filter() with name argument more obvious
With a client name, the QMP command is specified to return a list of
one element.  This isn't locally obvious in the code.  Make it so.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 15:58:07 +02:00
Hani Benhabiles
2da1b3abbc monitor: Add device_add and device_del completion.
Also fix device_add completion including non-hotpluggable devices.

Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:37:12 -04:00
Hani Benhabiles
bfa40f77af monitor: Add command_completion callback to mon_cmd_t.
Convert object_add and object_del commands to use the new callback.

Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:27:49 -04:00
Hani Benhabiles
f7bdc41acc monitor: Fix drive_del id argument type completion.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:59 -04:00
Cole Robinson
073a341151 error: Remove some unused headers
Makes it a bit clear how the interdependencies work.

Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:59 -04:00
Cole Robinson
0b15abfcbc qerror.h: Replace QERR_NOT_SUPPORTED with QERR_UNSUPPORTED
The former is only used twice, the latter is used over 30 times, and
has a nicer error message.

Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:59 -04:00
Cole Robinson
f231b88db1 qerror.h: Remove QERR defines that are only used once
Just hardcode them in the callers

Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:59 -04:00
Cole Robinson
d73f0beadb qerror.h: Remove unused error classes
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:59 -04:00
Cole Robinson
4ad417baa4 error: Print error_report() to stderr if using qmp
monitor_printf will drop the requested output if cur_mon is qmp (for
good reason). However these messages are often helpful for debugging
issues with via libvirt.

If we know the message won't hit the monitor, send it to stderr.

Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:58 -04:00
Cole Robinson
4a66d3bf9a monitor: Remove unused monitor_print_filename
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:58 -04:00
Cole Robinson
d876f60d14 error: Privatize error_print_loc
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:58 -04:00
Cole Robinson
027a79c373 vnc: Remove default_mon usage
These errors don't seem user initiated, so forcibly printing to the
monitor doesn't seem right. Just use error_report.

Cc: Anthony Liguori <aliguori@amazon.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:58 -04:00
Cole Robinson
02d1608980 slirp: Remove default_mon usage
These errors don't seem user initiated, so forcibly printing to the
monitor doesn't seem right. Just use error_report.

Drop lprint since it's now unused.

Cc: Jan Kiszka <jan.kiszka@siemens.com>

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25 09:19:58 -04:00
Peter Maydell
411f491e0a Merge remote-tracking branch 'remotes/rth/tags/tgt-axp-pull-20140424' into staging
target-alpha queue pull for 20140424

# gpg: Signature made Thu 24 Apr 2014 20:44:23 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/tgt-axp-pull-20140424: (40 commits)
  target-alpha: Remove cpu_unique, cpu_sysval, cpu_usp
  target-alpha: Tidy alpha_translate_init
  target-alpha: Don't issue goto_tb under singlestep
  target-alpha: Use non-local temps for zero/sink
  target-alpha: Use extract to get insn fields
  target-alpha: Convert mfpr/mtpr to source/sink
  target-alpha: Convert gen_cpys et al to source/sink
  target-alpha: Convert gen_fcvtlq/ql to source/sink
  target-alpha: Convert gen_fcmov to source/sink
  target-alpha: Convert gen_bcond to source/sink
  target-alpha: Convert most ieee insns to source/sink
  target-alpha: Convert gen_ieee_input to source/sink
  target-alpha: Convert MVIOP2 to source/sink
  target-alpha: Convert ARITH3 to source/sink
  target-alpha: Convert FARITH3 to source/sink
  target-alpha: Convert FARITH2 to source/sink
  target-alpha: Convert gen_zap/not to source/sink
  target-alpha: Convert gen_ins_h/l to source/sink
  target-alpha: Convert gen_ext_h/l to source/sink
  target-alpha: Convert gen_msk_h/l to source/sink
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-25 13:25:22 +01:00
Nathan Rossi
f663faac3e net: xilinx_axienet.c: Add phy soft reset bit clearing
Clear the BMCR Reset when writing to registers.

Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
[ PC:
 * Trivial style fixes to commit message
]
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 13:40:10 +02:00
Igor Ryzhov
b925965294 net/net.c: Remove unnecessary semicolon
Signed-off-by: Igor Ryzhov <iryzhov@arccn.ru>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 13:40:04 +02:00
Prasad Joshi
16cf0b2b34 pcnet: remove duplicate assignment
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 13:40:03 +02:00
Pankaj Gupta
13a12f869b tap: Avoid extra iterations while closing file fd
Avoid iterations for fd 0, 1 & 2 when we are closing file fds in child process.

Signed-off-by: Pankaj Gupta <pagupta@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-25 13:40:03 +02:00
Peter Maydell
7931b05987 Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches

# gpg: Signature made Wed 23 Apr 2014 11:02:29 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream:
  block/cloop: use PRIu32 format specifier for uint32_t
  vmdk: Fix "%x" to PRIx32 in format strings for cid
  qemu-img: Improve error messages
  qemu-iotests: Check common namespace for id and node-name
  block: Catch duplicate IDs in bdrv_new()
  qemu-img: Avoid duplicate block device IDs
  block: Add errp to bdrv_new()
  convert fprintf() calls to error_setg() in block/qed.c:bdrv_qed_create()
  block: Remove -errno return value from bdrv_assign_node_name
  curl: Replaced old error handling with error reporting API.
  block: Handle error of bdrv_getlength in bdrv_create_dirty_bitmap
  vmdk: Fix %d and %lld to PRI* in format strings
  block: Check bdrv_getlength() return value in bdrv_make_zero()
  block: Catch integer overflow in bdrv_rw_co()
  block: Limit size to INT_MAX in bdrv_check_byte_request()
  block: Fix nb_sectors check in bdrv_check_byte_request()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-25 12:22:37 +01:00
Christian Borntraeger
44b0c0bbb5 s390x/kvm: sync gbea and pp register
We also need to sync guest breaking event address and program parameter
register for migration support.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-04-25 12:59:57 +02:00
Christian Borntraeger
860643bc5a s390x/kvm: rework KVM synchronize to tracing for some ONEREGS
Some ONE_REGS on s390 are not protected by a capability. Older kernels
might not provide those and return an error. Fortunately these registers
are only critical for the migration path. There is no need to error out
on reset and normal runtime. Furthermore, these kernels don't provide
a proper dirty bitmap anyway, so let's use tracing for those errors.

Also provide generic one reg helper to simplify the code.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-04-25 12:59:57 +02:00
Cornelia Huck
9ffd26859d linux-headers update
linux-headers update against v3.15-rc2 (a798c10f)

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-04-25 12:59:57 +02:00
David Hildenbrand
8c0124490b s390x: empty function stubs in preparation for __KVM_HAVE_GUEST_DEBUG
This patch creates empty function stubs (used by the gdbserver) in preparation
for the hw debugging support by kvm on s390, which will enable the
__KVM_HAVE_GUEST_DEBUG define in the linux headers and require these methods on
the qemu side.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2014-04-25 11:07:02 +02:00
Peter Maydell
0e96643c98 Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-5' into staging
usb: mtp filesharing

# gpg: Signature made Wed 23 Apr 2014 09:28:37 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-usb-5:
  usb: mtp filesharing
  usb: add CompatibleID support to msos

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-24 16:16:57 +01:00
Peter Maydell
ad600a4d49 Merge remote-tracking branch 'remotes/rth/tags/tcg-next-20140422' into staging
Pull tcg 2014-04-22

# gpg: Signature made Tue 22 Apr 2014 22:00:04 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/tcg-next-20140422:
  tcg: Use HOST_WORDS_BIGENDIAN
  tcg: Fix fallback from muls2_i64 to mulu2_i64
  tcg: Use tcg_gen_mulu2_i32 in tcg_gen_muls2_i32
  tcg: Relax requirement for mulu2_i32 on 32-bit hosts
  tcg-s390: Remove W constraint
  tcg-sparc: Use the type parameter to tcg_target_const_match
  tcg-ppc64: Use the type parameter to tcg_target_const_match
  tcg-aarch64: Remove w constraint
  tcg: Add TCGType parameter to tcg_target_const_match
  tcg: Fix out of range shift in deposit optimizations
  tci: Mask shift counts to avoid undefined behavior
  tcg: Mask shift quantities while folding
  tcg: Use "unspecified behavior" for shifts
  tcg: Fix warning (1 bit signed bitfield entry) and replace int by bool

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-24 15:24:52 +01:00
Peter Maydell
ba3627ec38 Merge remote-tracking branch 'remotes/rth/tags/tcg-ia64-pull-20140421' into staging
Pull for 20140421

# gpg: Signature made Mon 21 Apr 2014 17:57:24 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/tcg-ia64-pull-20140421:
  tcg-ia64: Convert to new ldst opcodes
  tcg-ia64: Move part of softmmu slow path out of line
  tcg-ia64: Convert to new ldst helpers
  tcg-ia64: Reduce code duplication in tcg_out_qemu_ld
  tcg-ia64: Move tlb addend load into tlb read
  tcg-ia64: Move bswap for store into tlb load
  tcg-ia64: Re-bundle the tlb load
  tcg-ia64: Optimize small arguments to exit_tb

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-24 14:14:51 +01:00
Peter Maydell
4b8abfb78e Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-04-18' into staging
trivial patches for 2014-04-18

# gpg: Signature made Fri 18 Apr 2014 07:36:15 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
#      Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514  66A7 BEE5 9D74 A4C3 D7DB

* remotes/mjt/tags/trivial-patches-2014-04-18:
  Fix grammar in comment
  doc: grammify "allows to"
  configure: Remove redundant message for -Werror
  scripts: add sample model file for Coverity Scan
  xbzrle.c: Avoid undefined behaviour with signed arithmetic
  int128.h: Avoid undefined behaviours involving signed arithmetic
  hw/ide/ahci.c: Avoid shift left into sign bit
  net: Report error when device / hub combo is not found.
  configure: Fix indentation of help for --enable/disable-debug-info
  qga: trivial fix for unclear documentation of guest-set-time
  vl: Report accelerator not supported for target more nicely

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-24 13:22:16 +01:00
Stefan Hajnoczi
370e681629 block/cloop: use PRIu32 format specifier for uint32_t
PRIu32 is the format string specifier for uint32_t, let's use it.
Variables ->block_size, ->n_blocks, and i are all uint32_t.

Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-23 11:34:10 +02:00
Gerd Hoffmann
840a178c94 usb: mtp filesharing
Implementation of a USB Media Transfer Device device for easy
filesharing.  Read-only.  No access control inside qemu, it will
happily export any file it is able to open to the guest, i.e.
standard unix access rights for the qemu process apply.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-23 10:28:14 +02:00
Fam Zheng
9b17031ac4 vmdk: Fix "%x" to PRIx32 in format strings for cid
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 14:14:30 +02:00
Fam Zheng
ac1307abfe qemu-img: Improve error messages
Previously, when there is a user error in argv parsing, qemu-img prints
help text and exits.

Add an error_exit function to print a helpful error message and a hint
to run 'qemu-img --help' for more information.

As a bonus, "qemu-img <cmd> --help" now has a more reasonable exit code
0.

In the future the help text should be split by sub command, and only
print the information for the specified command.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 13:47:46 +02:00
Gerd Hoffmann
409951f552 usb: add CompatibleID support to msos
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-22 12:40:57 +02:00
Kevin Wolf
90d9d30152 qemu-iotests: Check common namespace for id and node-name
A name that is taken by an ID can't be taken by a node-name at the same
time. Check that conflicts are correctly detected.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
2014-04-22 12:12:30 +02:00
Kevin Wolf
f2d953ec31 block: Catch duplicate IDs in bdrv_new()
Since commit f298d071, block devices added with blockdev-add don't have
a QemuOpts around in dinfo->opts. Consequently, we can't rely any more
on QemuOpts catching duplicate IDs for block devices.

This patch adds a new check for duplicate IDs to bdrv_new(), and moves
the existing check that the ID isn't already taken for a node-name there
as well.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2014-04-22 12:00:28 +02:00
Kevin Wolf
9ffe333276 qemu-img: Avoid duplicate block device IDs
qemu-img used to use "image" as ID for all block devices. This means
that e.g. img_convert() ended up with potentially multiple source images
and one target image, all with the same ID. The next patch will catch
this and fail to open the block device.

This patch makes sure that qemu-img uses meaningful unique IDs for the
block devices it uses.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2014-04-22 12:00:24 +02:00
Kevin Wolf
98522f63f4 block: Add errp to bdrv_new()
This patch adds an errp parameter to bdrv_new() and updates all its
callers. The next patches will make use of this in order to check for
duplicate IDs. Most of the callers know that their ID is fine, so they
can simply assert that there is no error.

Behaviour doesn't change with this patch yet as bdrv_new() doesn't
actually assign errors to errp.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2014-04-22 12:00:20 +02:00
Aakriti Gupta
5ff679b47d convert fprintf() calls to error_setg() in block/qed.c:bdrv_qed_create()
This patch converts fprintf() calls to error_setg() in block/qed.c:bdrv_qed_create()
(error_setg() is part of error reporting API in include/qapi/error.h)

Signed-off-by: Aakriti Gupta <aakritty@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 11:57:02 +02:00
Kevin Wolf
636ea3708c block: Remove -errno return value from bdrv_assign_node_name
It takes an errp argument. That's enough for error handling.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 11:57:02 +02:00
Maria Kustova
acd7fdc6d8 curl: Replaced old error handling with error reporting API.
Signed-off-by: Maria Kustova <maria.k@catit.be>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 11:57:02 +02:00
Fam Zheng
b8afb520e4 block: Handle error of bdrv_getlength in bdrv_create_dirty_bitmap
bdrv_getlength could fail, check the return value before using it.
Return NULL and set errno if it fails. Callers are updated to handle
the error case.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 11:57:02 +02:00
Fam Zheng
4ab9dab5b9 vmdk: Fix %d and %lld to PRI* in format strings
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 11:57:02 +02:00
Kevin Wolf
9ce10c0bdc block: Check bdrv_getlength() return value in bdrv_make_zero()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-22 11:57:02 +02:00
Kevin Wolf
da15ee5134 block: Catch integer overflow in bdrv_rw_co()
Insanely large requests could cause an integer overflow in
bdrv_rw_co() while converting sectors to bytes. This patch catches the
problem and returns an error (if we hadn't overflown the integer here,
bdrv_check_byte_request() would have rejected the request, so we're not
breaking anything that was supposed to work before).

We actually do have a test case that triggers behaviour where we
accidentally let such a request pass, so that it would return success,
but read 0 bytes instead of the requested 4 GB. It fails now like it
should.

If the vdi block driver wants to be able to deal with huge images, it
can't read the whole block bitmap at once into memory like it does
today, but needs to use a metadata cache like qcow2 does.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-04-22 11:57:02 +02:00
Kevin Wolf
1dd3a44753 block: Limit size to INT_MAX in bdrv_check_byte_request()
Commit 8f4754ed intended to protect against integer overflow bugs in
block drivers by making sure that a single request that is passed to
drivers is no longer than INT_MAX bytes.

However, meanwhile there are some callers that don't use that code path
any more but call bdrv_check_byte_request() directy, so let's add a
check there as well.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-22 11:57:02 +02:00
Kevin Wolf
54db38a479 block: Fix nb_sectors check in bdrv_check_byte_request()
nb_sectors is signed, check for negative values.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-04-22 11:57:02 +02:00
Richard Henderson
02eb19d0ec tcg: Use HOST_WORDS_BIGENDIAN
Instead of rolling a local TCG_TARGET_WORDS_BIGENDIAN.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:37 -07:00
Richard Henderson
662deb908f tcg: Fix fallback from muls2_i64 to mulu2_i64
Brown Bag sez, don't put the fallback code into the wrong function.
Also, check for muluh_i64 and use tcg_gen_mulu2_i64 instead of raw ops.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:37 -07:00
Richard Henderson
f46fc4e6a9 tcg: Use tcg_gen_mulu2_i32 in tcg_gen_muls2_i32
Rather than hard-coding use of mulu2_i32, allow muluh_i32.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:37 -07:00
Richard Henderson
df9ebea53e tcg: Relax requirement for mulu2_i32 on 32-bit hosts
Instead require either mulu2_i32 or muluh_i32.  The code in tcg-op.h
already supports looking for both.  Previous incomplete conversion?

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:37 -07:00
Richard Henderson
671c835b7d tcg-s390: Remove W constraint
Now redundant with the type parameter to tcg_target_const_match.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
4b304cfae1 tcg-sparc: Use the type parameter to tcg_target_const_match
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
1194dcba22 tcg-ppc64: Use the type parameter to tcg_target_const_match
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
170bf9315b tcg-aarch64: Remove w constraint
Now redundant with the type parameter to tcg_target_const_match.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
f6c6afc1d4 tcg: Add TCGType parameter to tcg_target_const_match
Most 64-bit targets need to be able to ignore the high bits
of a TCG_TYPE_I32 value.

Suggested-by: Stuart Brady <sdb@zubnet.me.uk>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
d998e555d2 tcg: Fix out of range shift in deposit optimizations
By inspection, for a deposit(x, y, 0, 64), we'd have a shift of (1<<64)
and everything else falls apart.  But we can reuse the existing deposit
logic to get this right.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
1976cccec8 tci: Mask shift counts to avoid undefined behavior
TCG now requires unspecified behavior rather than a potential crash,
bring the C shift within the letter of the law.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
50c5c4d125 tcg: Mask shift quantities while folding
The TCG result would be undefined, but we can at least produce one
plausible result and avoid triggering the wrath of analysis tools.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Richard Henderson
20022fa15f tcg: Use "unspecified behavior" for shifts
Change the definition such that shifts are not allowed to crash
for any input.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Stefan Weil
ad5171dbd4 tcg: Fix warning (1 bit signed bitfield entry) and replace int by bool
Static code analyzers complain about signed bitfields with only a single
bit. is_ld is used as a boolean value, so make it bool.

ppc64 already used bool for the 2nd argument is_ld of the local function
add_qemu_ldst_label. Modify all other TCG targets to do follow this
example.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-18 16:57:36 -07:00
Stefan Weil
b36dc67b95 Fix grammar in comment
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Michael Tokarev
9d85d55732 doc: grammify "allows to"
English language grammar does not allow usage
of the word "allows" directly followed by an
infinitive, declaring constructs like "something
allows to do somestuff" un-grammatical.  Often
it is possible to just insert "one" between "allows"
and "to" to make the construct grammatical, but
usually it is better to re-phrase the statement.

This patch tries to fix 4 examples of "allows to"
usage in qemu doc, but does not address comments
in the code with similar constructs.  It also adds
missing "the" in the same line.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Stefan Weil
2300aed15d configure: Remove redundant message for -Werror
The compiler flag -Werror is printed (or not printed) as any other
compiler flag which is part of QEMU_CFLAGS.

Therefore an extra output line for -Werror is redundant and can be removed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Paolo Bonzini
e40cdb0e6e scripts: add sample model file for Coverity Scan
This is the model file that is being used for the QEMU project's scans
on scan.coverity.com.  It fixed about 30 false positives (10% of the
total) and exposed about 60 new memory leaks.

The file is not automatically used; changes to it must be propagated
to the website manually by an admin (right now Markus, Peter and me
are admins).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Peter Maydell
968fc24d84 xbzrle.c: Avoid undefined behaviour with signed arithmetic
Use unsigned types for doing bitwise arithmetic in the xzbrle
calculations, to avoid undefined behaviour:

 xbzrle.c:99:49: runtime error: left shift of 72340172838076673
 by 7 places cannot be represented in type 'long'

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Peter Maydell
423d00c857 int128.h: Avoid undefined behaviours involving signed arithmetic
Add casts when we're performing arithmetic on the .hi parts of an
Int128, to avoid undefined behaviour.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Peter Maydell
ee25595f01 hw/ide/ahci.c: Avoid shift left into sign bit
Add U suffix to avoid shifting left into the sign bit, which
is undefined behaviour.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Hani Benhabiles
86e117724a net: Report error when device / hub combo is not found.
Also convert nearby monitor_printf() call to error_report().

Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Peter Maydell
d61ce900b9 configure: Fix indentation of help for --enable/disable-debug-info
The help text for the --enable-debug-info and --disable-debug-info
command line options was misindented: delete the stray extra space
and bring it in to line with everything else.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Amos Kong
1634df567d qga: trivial fix for unclear documentation of guest-set-time
We mixed the use of "guest time", "system time", "hardware time",
"RTC" in documentation, it's unclear.

This patch just added two remarks of RTC and replace two "guest time"
by "guest's system time".

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Chen Gang
b321afbefd vl: Report accelerator not supported for target more nicely
When you ask for an accelerator not supported for your target, you get
a bogus "accelerator does not exist" message:

  $ qemu-system-arm -machine none,accel=kvm
  KVM not supported for this target
  "kvm" accelerator does not exist.
  No accelerator found!

Suppress it.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-04-18 10:33:36 +04:00
Richard Henderson
0374f5089a tcg-ia64: Convert to new ldst opcodes
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:20 -04:00
Richard Henderson
3bf16cb31a tcg-ia64: Move part of softmmu slow path out of line
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:20 -04:00
Richard Henderson
4bdd547aaa tcg-ia64: Convert to new ldst helpers
Still inline, but updated to the new routines.  Always use the LE
helpers, reusing the bswap between the fast and slot paths.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:19 -04:00
Richard Henderson
af9fe31070 tcg-ia64: Reduce code duplication in tcg_out_qemu_ld
The only differences were in the bswap insns emitted.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:19 -04:00
Richard Henderson
1f91f39219 tcg-ia64: Move tlb addend load into tlb read
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:18 -04:00
Richard Henderson
b672cf66c3 tcg-ia64: Move bswap for store into tlb load
Saving at least two cycles per store, and cleaning up the code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:17 -04:00
Richard Henderson
4c186ee2cf tcg-ia64: Re-bundle the tlb load
This sequencing requires 5 stop bits instead of 6, and has room left
over to pre-load the tlb addend, and bswap data prior to being stored.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:17 -04:00
Richard Henderson
dcf91778ca tcg-ia64: Optimize small arguments to exit_tb
Saves one bundle for the common case of exit_tb 0.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 16:56:16 -04:00
Peter Maydell
2d03b49c3f Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20140417-1' into staging
target-arm queue:
 * AArch64 system mode support; this is all the CPU emulation code
   but not the virt board support
 * cadence_ttc match register bugfix
 * Allwinner A10 PIC, PIT and ethernet fixes
   [with update to avoid duplicate typedef]
 * zynq-slcr rewrite
 * cadence_gem bugfix
 * fix for SMLALD/SMLSLD insn in A32
 * fix for SQXTUN in A64

# gpg: Signature made Thu 17 Apr 2014 21:35:57 BST using RSA key ID 14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"

* remotes/pmaydell/tags/pull-target-arm-20140417-1: (51 commits)
  target-arm: A64: fix unallocated test of scalar SQXTUN
  arm: translate.c: Fix smlald Instruction
  net: cadence_gem: Make phy respond to broadcast
  misc: zynq_slcr: Make DB_PRINTs always compile
  misc: zynq_slcr: Convert SBD::init to object init
  misc: zynq-slcr: Rewrite
  allwinner-emac: update irq status after writes to interrupt registers
  allwinner-emac: set autonegotiation complete bit on link up
  allwinner-a10-pit: implement prescaler and source selection
  allwinner-a10-pit: use level triggered interrupts
  allwinner-a10-pit: avoid generation of spurious interrupts
  allwinner-a10-pic: fix behaviour of pending register
  allwinner-a10-pic: set vector address when an interrupt is pending
  timer: cadence_ttc: Fix match register write logic
  target-arm/gdbstub64.c: remove useless 'break' statement.
  target-arm: Dump 32-bit CPU state if 64 bit CPU is in AArch32
  target-arm: Handle the CPU being in AArch32 mode in the AArch64 set_pc
  target-arm: Make Cortex-A15 CBAR read-only
  target-arm: Implement CBAR for Cortex-A57
  target-arm: Implement Cortex-A57 implementation-defined system registers
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:37:26 +01:00
Alex Bennée
e44a90c596 target-arm: A64: fix unallocated test of scalar SQXTUN
The test for the U bit was incorrectly inverted in the scalar case of SQXTUN.
This doesn't affect the vector case as the U bit is used to select XTN(2).

Reported-by: Hao Liu <hao.liu@arm.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:07 +01:00
Peter Crosthwaite
33bbd75a7c arm: translate.c: Fix smlald Instruction
The smlald (and probably smlsld) instruction was doing incorrect sign
extensions of the operands amongst 64bit result calculation. The
instruction psuedo-code is:

 operand2 = if m_swap then ROR(R[m],16) else R[m];
 product1 = SInt(R[n]<15:0>) * SInt(operand2<15:0>);
 product2 = SInt(R[n]<31:16>) * SInt(operand2<31:16>);
 result = product1 + product2 + SInt(R[dHi]:R[dLo]);
 R[dHi] = result<63:32>;
 R[dLo] = result<31:0>;

The result calculation should be done in 64 bit arithmetic, and hence
product1 and product2 should be sign extended to 64b before calculation.

The current implementation was adding product1 and product2 together
then sign-extending the intermediate result leading to false negatives.

E.G. if product1 = product2 = 0x4000000, their sum = 0x80000000, which
will be incorrectly interpreted as -ve on sign extension.

We fix by doing the 64b extensions on both product1 and product2 before
any addition/subtraction happens.

We also fix where we were possibly incorrectly setting the Q saturation
flag for SMLSLD, which the ARM ARM specifically says is not set.

Reported-by: Christina Smith <christina.smith@xilinx.com>
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 2cddb6f5a15be4ab8d2160f3499d128ae93d304d.1397704570.git.peter.crosthwaite@xilinx.com
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:07 +01:00
Peter Crosthwaite
5538937368 net: cadence_gem: Make phy respond to broadcast
Phys must respond to address 0 by specification. Implement.

Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 6f4d53b04ddbfb19895bfb61a595e69f1c08859a.1396594056.git.peter.crosthwaite@xilinx.com
Reviewed-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:07 +01:00
Peter Crosthwaite
6954a1cd97 misc: zynq_slcr: Make DB_PRINTs always compile
Change the DB_PRINT macro over to a regular if() rather than
conditional compilation to give constant compile testing of formats.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 942477847353c5cff5f45a228cc88c633dc012f3.1396503037.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:07 +01:00
Peter Crosthwaite
15e3611e1c misc: zynq_slcr: Convert SBD::init to object init
To bring it up to date with styling guidelines.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 2e837af80a18216c21e73241032e048f39d78b99.1396503037.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:07 +01:00
Peter Crosthwaite
db302f8f93 misc: zynq-slcr: Rewrite
Near total rewrite of this device model. It is stylistically
obsolete, has numerous coverity fails and is not up to date with latest
Xilinx documentation. Fix.

The registers are flattened into a single array. This greatly simplifies
the MMIO accessor functions.

We take the oppurtunity to update the register Macro definitions to
match the latest TRM. Xilinx has de-documented some regs hence there are
some straight deletions. We only do this however in the case or a stock
read-as-written reset-zero register. Non-zero resets are always
preserved. New register definitions are added as needed.

This all comes with a VMSD version break as the union layout from before
was a bit strange and we are better off without it.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 3aa016167b352ed224666909217137285fd3351d.1396503037.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Beniamino Galvani
6619bc5c55 allwinner-emac: update irq status after writes to interrupt registers
The irq line status must be updated after writes to the INT_CTL and
INT_STA registers.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-8-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Beniamino Galvani
103db49a10 allwinner-emac: set autonegotiation complete bit on link up
Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-7-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Beniamino Galvani
286226a479 allwinner-a10-pit: implement prescaler and source selection
This implements the prescaler and source fields of the timer control
register. The source for each timer can be selected among 4 clock
inputs whose frequencies are set through model properties.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-6-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Beniamino Galvani
a63f9f85e3 allwinner-a10-pit: use level triggered interrupts
Convert the interrupt generation logic to the use of level triggered
interrupts.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-5-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Beniamino Galvani
323a8771cf allwinner-a10-pit: avoid generation of spurious interrupts
The model was generating interrupts for all enabled timers after the
expiration of one of them. Avoid this by passing explicitly the timer
index to the callback function.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Li Guang <lig.fnst@cn.fujitsu.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-4-git-send-email-b.galvani@gmail.com
[PMM: avoid duplicate typedef of AwA10PITState]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Beniamino Galvani
2237094d96 allwinner-a10-pic: fix behaviour of pending register
The pending register is read-only and the value returned upon a read
reflects the state of irq input pins (interrupts are level triggered).
This patch implements such behaviour.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Li Guang <lig.fnst@cn.fujitsu.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-3-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Beniamino Galvani
1c70aa6264 allwinner-a10-pic: set vector address when an interrupt is pending
This patch implements proper updating of the vector register which
should hold, according to the A10 user manual, the vector address for
the interrupt currently active on the CPU IRQ input.

Interrupt priority is not implemented at the moment and thus the first
pending interrupt is returned.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Li Guang <lig.fnst@cn.fujitsu.com>
Message-id: 1395771730-16882-2-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Peter Crosthwaite
f727d0e621 timer: cadence_ttc: Fix match register write logic
This switch logic should not fall through. Fix.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 74147b4c017c904364955cc73107f90e6ac8ba74.1396326389.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Chen Gang
b5cde1da0a target-arm/gdbstub64.c: remove useless 'break' statement.
Clean up useless 'break' statement after 'return' statement.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Peter Maydell
177311157c target-arm: Dump 32-bit CPU state if 64 bit CPU is in AArch32
For system mode, we may have a 64 bit CPU which is currently executing
in AArch32 state; if we're dumping CPU state to the logs we should
therefore show the correct state for the current execution state,
rather than hardwiring it based on the type of the CPU. For consistency
with how we handle translation, we leave the 32 bit dump function
as the default, and have it hand off control to the 64 bit dump code
if we're in AArch64 mode.

Reported-by: Rob Herring <rob.herring@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 21:34:06 +01:00
Peter Maydell
7633378d5f target-arm: Handle the CPU being in AArch32 mode in the AArch64 set_pc
The AArch64 implementation of the set_pc method needs to be updated to
handle the possibility that the CPU is in AArch32 mode; otherwise there
are weird crashes when doing interprocessing in system emulation mode
when an interrupt occurs and we fail to resynchronize the 32-bit PC
with the TB we need to execute next.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:06 +01:00
Peter Maydell
c29f9a0a29 target-arm: Make Cortex-A15 CBAR read-only
The Cortex-A15's CBAR register is actually read-only (unlike that
of the Cortex-A9). Correct our model to match the hardware.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:06 +01:00
Peter Maydell
f318cec6ad target-arm: Implement CBAR for Cortex-A57
The Cortex-A57, like most of the other ARM cores, has a CBAR
register which defines the base address of the per-CPU
peripherals. However it has a 64-bit view as well as a
32-bit view; expand the QOM reset-cbar property from UINT32
to UINT64 so this can be specified, and implement the
32-bit and 64-bit views of a 64-bit CBAR.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:06 +01:00
Peter Maydell
377a44ec8f target-arm: Implement Cortex-A57 implementation-defined system registers
Implement a subset of the Cortex-A57's implementation defined system
registers. We provide RAZ/WI or reads-as-constant/writes-ignored
implementations of the various control and syndrome reigsters.
We do not implement registers which provide direct access to and
manipulation of the L1 cache, since QEMU doesn't implement caches.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:06 +01:00
Peter Maydell
3933443e38 target-arm: Implement RVBAR register
Implement the AArch64 RVBAR register, which indicates the reset
address. Since the reset address is implementation defined and
usually configurable by setting config signals in hardware, we
also provide a QOM property so it can be set at board level if
necessary.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:06 +01:00
Peter Maydell
19525524a7 target-arm: Implement AArch64 address translation operations
Implement the AArch64 address translation operations.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:06 +01:00
Peter Maydell
f32cdad55d target-arm: Implement auxiliary fault status registers
Implement the auxiliary fault status registers AFSR0_EL1 and
AFSR1_EL1. These are present on v7 and later, and have IMPDEF
behaviour; we choose to RAZ/WI for all cores.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
9449fdf61f target-arm: Replace wildcarded cpreg definitions with precise ones for ARMv8
Many of the reginfo definitions in cp_reginfo[] use CP_ANY wildcards.
This is for a combination of reasons:
 * early ARM implementations really did underdecode
 * earlier versions of QEMU underdecoded and we can't tighten
   this up because we don't know if guests really require this or not
 * implementation convenience

For ARMv8 the architecture has tightened things up and system and
coprocessor registers are always specifically decoded. We take
advantage of this opportunity for a clean break by restricting
our CP_ANY wildcarded reginfo to pre-v8 CPUs, and providing
specifically decoded versions where necessary for v8 CPUs.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
00a29f3ddc target-arm: Don't expose wildcard ID register definitions for ARMv8
In ARMv8 the 32 bit coprocessor ID register space is tidied up to
remove the wildcarded aliases of the MIDR and the RAZ behaviour
for the unassigned space where crm = 3..7. Make sure we don't
expose thes wildcards for v8 cores. This means we need to have
a specific implementation for REVIDR, an IMPDEF register which
may be the same as the MIDR (and which we always implement as such).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
85acfa9c38 target-arm: Remove THUMB2EE feature from AArch64 'any' CPU
The AArch64 usermode 'any' CPU type was accidentally specified
with the ARM_FEATURE_THUMB2EE bit set. This is incorrect since
ARMv8 removes Thumb2EE completely. Since we never implemented
Thumb2EE anyway having the feature bit set was fairly harmless
for user-mode, but the correct thing is to not set it at all.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
1090b9c6cc target-arm: Implement ISR_EL1 register
Implement the ISR_EL1 register. This is actually present in
ARMv7 as well but was previously unimplemented. It is a
read-only register that indicates whether interrupts are
currently pending.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
2eef0bf821 target-arm: Implement AArch64 view of ACTLR
Implement the AArch64 view of the ACTLR (auxiliary control
register). Note that QEMU internally tends to call this
AUXCR for historical reasons.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
014406b510 target-arm: Implement AArch64 view of CONTEXTIDR
Implement AArch64 view of the CONTEXTIDR register.
We tighten up the condition when we flush the TLB on a CONTEXTIDR
write to avoid needlessly flushing the TLB every time on a 64
bit system (and also on a 32 bit system using LPAE, as a bonus).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
0ff644a786 target-arm: Implement AArch64 views of AArch32 ID registers
All the AArch32 ID registers are visible from AArch64
(in addition to the AArch64-specific ID_AA64* registers).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
cb1fa941c1 target-arm: Add Cortex-A57 processor
Add Cortex-A57 processor.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:05 +01:00
Peter Maydell
a50c0f5133 target-arm: Implement ARMv8 MVFR registers
For ARMv8 there are two changes to the MVFR media feature registers:
 * there is a new MVFR2 which is accessible from 32 bit code
 * 64 bit code accesses these via the usual sysreg instructions
   rather than with a floating-point specific instruction

Implement this.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Rob Herring
52e60cdd34 target-arm: Implement AArch64 EL1 exception handling
Implement exception handling for AArch64 EL1. Exceptions from AArch64 or
AArch32 EL0 are supported.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: fixed minor style nits; updated to match changes in
 previous patches; added some of the simpler cases of
 illegal-exception-return support]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
2f2a00aec9 target-arm: Move arm_log_exception() into internals.h
Move arm_log_exception() into internals.h so we can use it from
helper-a64.c for the AArch64 exception entry code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
a65f1de982 target-arm: Implement AArch64 SPSR_EL1
Implement the AArch64 SPSR_EL1. For compatibility with how KVM
handles SPSRs and with the architectural mapping between AArch32
and AArch64, we put this in the banked_spsr[] array in the slot
that is used for SVC in AArch32. This means we need to extend the
array from uint32_t to uint64_t, which requires some reworking
of the 32 bit KVM save/restore code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
f502cfc207 target-arm: Implement SP_EL0, SP_EL1
Implement handling for the AArch64 SP_EL0 system register.
This holds the EL0 stack pointer, and is only accessible when
it's not being used as the stack pointer, ie when we're in EL1
and EL1 is using its own stack pointer. We also provide a
definition of the SP_EL1 register; this isn't guest visible
as a system register for an implementation like QEMU which
doesn't provide EL2 or EL3; however it is useful for ensuring
the underlying state is migrated.

We need to update the state fields in the CPU state whenever
we switch stack pointers; this happens when we take an exception
and also when SPSEL is used to change the bit in PSTATE which
indicates which stack pointer EL1 should use.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
a0618a1990 target-arm: Add AArch64 ELR_EL1 register.
Add the AArch64 ELR_EL1 register.

Note that this does not live in env->cp15: for KVM migration
compatibility we need to migrate it separately rather than
as part of the system registers, because the KVM-to-userspace
interface puts it in the struct kvm_regs rather than making
them visible via the ONE_REG ioctls.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Rob Herring
6cd8a2649a target-arm: Implement AArch64 views of fault status and data registers
Implement AArch64 views of ESR_EL1 and FAR_EL1, and make the 32 bit
DFSR, DFAR, IFAR share state with them as architecturally specified.
The IFSR doesn't share state with any AArch64 register visible at EL1,
so just rename the state field without widening it to 64 bits.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: Minor tweaks; fix some bugs involving inconsistencies between
 use of offsetof() or offsetoflow32() and struct field width]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
7e09797c29 target-arm: Use dedicated CPU state fields for ARM946 access bit registers
The ARM946 model currently uses the c5_data and c5_insn fields in the CPU
state struct to store the contents of its access permission registers.
This is confusing and a good source of bugs because for all the MMU-based
CPUs those fields are fault status and fault address registers, which
behave completely differently; they just happen to use the same cpreg
encoding. Split them out to use their own fields instead.

These registers are only present in PMSAv5 MPU systems (of which the
ARM946 is our only current example); PMSAv6 and PMSAv7 (which we have
no implementations of) handle access permissions differently. We name
the new state fields accordingly.

Note that this change fixes a bug where a data abort or prefetch abort
on the ARM946 would accidentally corrupt the access permission registers
because the interrupt handling code assumed the c5_data and c5_insn
fields were always fault status registers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
aca3f40b37 target-arm: A64: Implement DC ZVA
Implement the DC ZVA instruction, which clears a block of memory.
The fast path obtains a pointer to the underlying RAM via the TCG TLB
data structure so we can do a direct memset(), with fallback to a
simple byte-store loop in the slow path.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
9225d739e7 target-arm: Don't mention PMU in debug feature register
Suppress the ID_AA64DFR0_EL1 PMUVer field, even if the CPU specific
value claims that it exists. QEMU doesn't currently implement it,
and not advertising it prevents the guest from trying to use it
and getting UNDEFs on unimplemented registers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
This is arguably a hack, but otherwise Linux tries to prod
half a dozen PMU sysregs.
2014-04-17 21:34:04 +01:00
Rob Herring
2c8dd31863 target-arm: Add v8 mmu translation support
Add support for v8 page table walks. This supports stage 1 translations
for 4KB, 16KB and 64KB page sizes starting with 0 or 1 level.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: fix style nits, fold in 16/64K page support patch, use
 arm_el_is_aa64() to decide whether to do 64 bit page table walk]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:04 +01:00
Peter Maydell
2c7ffc414d target-arm: Fix VFP enables for AArch32 EL0 under AArch64 EL1
The current A32/T32 decoder bases its "is VFP/Neon enabled?" check
on the FPSCR.EN bit. This is correct if EL1 is AArch32, but for
an AArch64 EL1 the logic is different: it must act as if FPSCR.EN
is always set. Instead, trapping must happen according to CPACR
bits for cp10/cp11; these cover all of FP/Neon, including the
FPSCR/FPSID/MVFR register accesses which FPSCR.EN does not affect.
Add support for CPACR checks (which are also required for ARMv7,
but were unimplemented because Linux happens not to use them)
and make sure they generate exceptions with the correct syndrome.

We actually return incorrect syndrome information for cases
where FP is disabled but the specific instruction bit pattern
is unallocated: strictly these should be the Uncategorized
exception, not a "SIMD disabled" exception. This should be
mostly harmless, and the structure of the A32/T32 VFP/Neon
decoder makes it painful to put the 'FP disabled?' checks in
the right places.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
90e496386f target-arm: A64: Add assertion that FP access was checked
Because unallocated encodings generate different exception syndrome
information from traps due to FP being disabled, we can't do a single
"is fp access disabled" check at a high level in the decode tree.
To help in catching bugs where the access check was forgotten in some
code path, we set this flag when the access check is done, and assert
that it is set at the point where we actually touch the FP regs.

This requires us to pass the DisasContext to the vec_reg_offset
and fp_reg_offset functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
8c6afa6ab1 target-arm: A64: Correctly fault FP/Neon if CPACR.FPEN set
For the A64 instruction set, the only FP/Neon disable trap
is the CPACR FPEN bits, which may indicate "enabled", "disabled"
or "disabled for EL0". Add a bit to the AArch64 tb flags indicating
whether FP/Neon access is currently enabled and make the decoder
emit code to raise exceptions on use of FP/Neon insns if it is not.

We use a new flag in DisasContext rather than borrowing the
existing vfp_enabled flag because the A32/T32 decoder is going
to need both.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
I'm aware this is a rather hard to review patch; sorry.
I have done an exhaustive check that we have fp access checks
in all code paths with the aid of the assertions added in the
next patch plus the code-coverage hack patch I posted to the
list earlier.

This patch is correct as of
09e037354 target-arm: A64: Add saturating accumulate ops (USQADD/SUQADD)
which was the last of the Neon insns to be added, so assuming
no refactoring of the code it should be fine.
2014-04-17 21:34:03 +01:00
Rob Herring
00892383c9 target-arm: Provide syndrome information for MMU faults
Set up the required syndrome information when we detect an MMU fault.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: split out from exception handling patch, tweaked to bring
 in line with how we create other kinds of syndrome information]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
d4a2dc675b target-arm: Add support for generating exceptions with syndrome information
Add new helpers exception_with_syndrome (for generating an exception
with syndrome information) and exception_uncategorized (for generating
an exception with "Unknown or Uncategorized Reason", which have a syndrome
register value of zero), and use them to generate the correct syndrome
information for exceptions which are raised directly from generated code.

This patch includes moving the A32/T32 gen_exception_insn functions
further up in the source file; they will be needed for "VFP/Neon disabled"
exception generation later.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
8bcbf37caa target-arm: Provide correct syndrome information for cpreg access traps
For exceptions taken to AArch64, if a coprocessor/system register
access fails due to a trap or enable bit then the syndrome information
must include details of the failing instruction (crn/crm/opc1/opc2
fields, etc). Make the decoder construct the syndrome information
at translate time so it can be passed at runtime to the access-check
helper function and used as required.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
abf1172fc6 target-arm: Define exception record for AArch64 exceptions
For AArch32 exceptions, the only information provided about
the cause of an exception is the individual exception type (data
abort, undef, etc), which we store in cs->exception_index. For
AArch64, the CPU provides much more detail about the cause of
the exception, which can be found in the syndrome register.
Create a set of fields in CPUARMState which must be filled in
whenever an exception is raised, so that exception entry can
correctly fill in the syndrome register for the guest.
This includes the information which in AArch32 appears in
the DFAR and IFAR (fault address registers) and the DFSR
and IFSR (fault status registers) for data aborts and
prefetch aborts, since if we end up taking the MMU fault
to AArch64 rather than AArch32 this will need to end up
in different system registers.

This patch does a refactoring which moves the setting of the
AArch32 DFAR/DFSR/IFAR/IFSR from the point where the exception
is raised to the point where it is taken. (This is no change
for cores with an MMU, retains the existing clearly incorrect
behaviour for ARM946 of trashing the MP access permissions
registers which share the c5_data and c5_insn state fields,
and has no effect for v7M because we don't implement its
MPU fault status or address registers.)

As a side effect of the cleanup we fix a bug in the AArch64
linux-user mode code where we were passing a 64 bit fault
address through the 32 bit c6_data/c6_insn fields: it now
goes via the always-64-bit exception.vaddress.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
c2b820fe58 target-arm: Implement AArch64 DAIF system register
Implement the DAIF system register which is a view of the
DAIF bits in PSTATE. To avoid needing a readfn, we widen
the daif field in CPUARMState to uint64_t.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
ccd380876b target-arm: Split out private-to-target functions into internals.h
Currently cpu.h defines a mixture of functions and types needed by
the rest of QEMU and those needed only by files within target-arm/.
Split the latter out into a new header so they aren't needlessly
exposed further than required.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-17 21:34:03 +01:00
Peter Maydell
c6138aabfb Merge remote-tracking branch 'remotes/rth/tcg-aarch-6-5' into staging
* remotes/rth/tcg-aarch-6-5: (25 commits)
  tcg-aarch64: Use tcg_out_mov in preference to tcg_out_movr
  tcg-aarch64: Prefer unsigned offsets before signed offsets for ldst
  tcg-aarch64: Introduce tcg_out_insn_3312, _3310, _3313
  tcg-aarch64: Merge aarch64_ldst_get_data/type into tcg_out_op
  tcg-aarch64: Introduce tcg_out_insn_3507
  tcg-aarch64: Support stores of zero
  tcg-aarch64: Implement TCG_TARGET_HAS_new_ldst
  tcg-aarch64: Pass qemu_ld/st arguments directly
  tcg-aarch64: Use TCGMemOp in qemu_ld/st
  tcg-aarch64: Use ADR to pass the return address to the ld/st helpers
  tcg-aarch64: Use tcg_out_call for qemu_ld/st
  tcg-aarch64: Avoid add with zero in tlb load
  tcg-aarch64: Implement tcg_register_jit
  tcg-aarch64: Introduce tcg_out_insn_3314
  tcg-aarch64: Reuse LR in translated code
  tcg-aarch64: Use CBZ and CBNZ
  tcg-aarch64: Create tcg_out_brcond
  tcg-aarch64: Use symbolic names for branches
  tcg-aarch64: Use adrp in tcg_out_movi
  tcg-aarch64: Special case small constants in tcg_out_movi
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 20:54:38 +01:00
Peter Maydell
5149e557d7 Open 2.1 development tree
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-04-17 20:39:32 +01:00
Richard Henderson
06ef8604e9 target-alpha: Remove cpu_unique, cpu_sysval, cpu_usp
Technically, these variables could have been referenced both via
offsets from env and as TCG registers, which would be illegal.
Of course, that could only be done from PALcode, and ours doesn't
do that.

But honestly, these are used infrequently enough that they don't
really need to be TCG registers.  We wind up with exactly the same
code if we follow the letter of the law and issue explicit ld/st.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
39acc64741 target-alpha: Tidy alpha_translate_init
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
e566be049a target-alpha: Don't issue goto_tb under singlestep
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
8f811b9a4a target-alpha: Use non-local temps for zero/sink
These values are no longer live across branches.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
a9e05a1ceb target-alpha: Use extract to get insn fields
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
0e154fe92c target-alpha: Convert mfpr/mtpr to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
ef3765cb95 target-alpha: Convert gen_cpys et al to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
e8d8fef48f target-alpha: Convert gen_fcvtlq/ql to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
6580935246 target-alpha: Convert gen_fcmov to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
76bff4f82f target-alpha: Convert gen_bcond to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
e20b8c04a3 target-alpha: Convert most ieee insns to source/sink
This one fixes a bug, previously noted as supressing exceptions
in the (unlikely) case the destination register was $f31.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
8b0190bbde target-alpha: Convert gen_ieee_input to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
f477ed3c11 target-alpha: Convert MVIOP2 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
cd2754addc target-alpha: Convert ARITH3 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
3d045dbca5 target-alpha: Convert FARITH3 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
baee04abba target-alpha: Convert FARITH2 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
b144be9e06 target-alpha: Convert gen_zap/not to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
5e5863ecf1 target-alpha: Convert gen_ins_h/l to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
9a734d64f9 target-alpha: Convert gen_ext_h/l to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:42 -07:00
Richard Henderson
9a8fa1bdad target-alpha: Convert gen_msk_h/l to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
83ebb7cd01 target-alpha: Convert gen_cmov to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
42774a56ec target-alpha: Convert ARITH3_EX to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
958683482c target-alpha: Convert gen_cmp to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
cd2d46fd21 target-alpha: Convert gen_store_conditional to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
595b8fdd54 target-alpha: Convert gen_load/store_mem to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
a4af30447b target-alpha: Convert opcode 0x1F to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
46010969f3 target-alpha: Convert opcode 0x1E to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
c67b67e511 target-alpha: Convert opcode 0x1C to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
1eaa1da7e4 target-alpha: Convert opcode 0x1B to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
8f56ced8aa target-alpha: Convert opcode 0x1A to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
89fe090bb3 target-alpha: Convert opcode 0x18 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
6b88b37c0e target-alpha: Convert opcode 0x17 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
075b8ddb9b target-alpha: Convert opcode 0x14 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
de4d3555fa target-alpha: Convert opcode 0x13 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
3bd67b7dab target-alpha: Convert opcode 0x12 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
db4a16458c target-alpha: Convert opcode 0x11 to source/sink
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:41 -07:00
Richard Henderson
194cfb43d5 target-alpha: Introduce functions for source/sink
This will allow cleaner handling of $31 and $f31.
Convert opcodes 0x08, 0x09, 0x10 as examples.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:40 -07:00
Richard Henderson
64f45e4991 target-alpha: Introduce REQUIRE_REG_31
We were missing quite a few checks for Ra or Rb required to be 31.
Further, the one place we did check we also checked for no literal
operand and the Handbook says nothing about that.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:40 -07:00
Richard Henderson
5238c88657 target-alpha: Introduce REQUIRE_TB_FLAG
The methods by which we check for cpu features varied wildly
across the function.  Using a nice macro cleans this up.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:40 -07:00
Paolo Bonzini
67debe3ae5 target-alpha: fix the braces
Conform to coding style, and avoid further occurrences of bugs due to
misplaced braces.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-17 11:47:40 -07:00
Richard Henderson
b825025f08 tcg-aarch64: Use tcg_out_mov in preference to tcg_out_movr
It's the more canonical interface.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:02 -04:00
Richard Henderson
a056c9faa4 tcg-aarch64: Prefer unsigned offsets before signed offsets for ldst
The assembler seems to prefer them, perhaps we should too.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:01 -04:00
Richard Henderson
3d4299f425 tcg-aarch64: Introduce tcg_out_insn_3312, _3310, _3313
Replace aarch64_ldst_op_data with AArch64LdstType, as it wasn't encoded
for the proper shift for the field and was confusing.

Merge aarch64_ldst_op_data, AArch64LdstType, and a few stray opcode bits
into a single I3312_* argument, eliminating some magic numbers from the
helper functions.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:01 -04:00
Richard Henderson
dc73dfd4bc tcg-aarch64: Merge aarch64_ldst_get_data/type into tcg_out_op
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:01 -04:00
Richard Henderson
edd8824cd4 tcg-aarch64: Introduce tcg_out_insn_3507
Cleaning up the implementation of REV and REV16 at the same time.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:01 -04:00
Richard Henderson
e81864a109 tcg-aarch64: Support stores of zero
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:01 -04:00
Richard Henderson
de61d14fa7 tcg-aarch64: Implement TCG_TARGET_HAS_new_ldst
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:01 -04:00
Richard Henderson
667b1cdd4e tcg-aarch64: Pass qemu_ld/st arguments directly
Instead of passing them the "args" array.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:00 -04:00
Richard Henderson
9e4177ad6d tcg-aarch64: Use TCGMemOp in qemu_ld/st
Making the bswap conditional on the memop instead of a compile-time test.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:00 -04:00
Richard Henderson
dc0c8aaf2c tcg-aarch64: Use ADR to pass the return address to the ld/st helpers
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:00 -04:00
Richard Henderson
ae7ab46aa8 tcg-aarch64: Use tcg_out_call for qemu_ld/st
In some cases, a direct branch will be in range.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:00 -04:00
Richard Henderson
6f4724672c tcg-aarch64: Avoid add with zero in tlb load
Some guest env are small enough to reach the tlb with only a 12-bit addition.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:00 -04:00
Richard Henderson
38d195aa05 tcg-aarch64: Implement tcg_register_jit
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:13:00 -04:00
Richard Henderson
95f72aa90a tcg-aarch64: Introduce tcg_out_insn_3314
Combines 4 other inline functions and tidies the prologue.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:59 -04:00
Richard Henderson
d82b78e48b tcg-aarch64: Reuse LR in translated code
It's obviously call-clobbered, but is otherwise unused.
Repurpose it as the TCG temporary.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:59 -04:00
Richard Henderson
3d9e69a238 tcg-aarch64: Use CBZ and CBNZ
A compare and branch against zero happens at the start of
every single TB.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:59 -04:00
Richard Henderson
cae1f6f3e6 tcg-aarch64: Create tcg_out_brcond
Rearrange code to put the compare and branch in the same place.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:59 -04:00
Richard Henderson
81d8a5ee19 tcg-aarch64: Use symbolic names for branches
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:59 -04:00
Richard Henderson
c6e310d938 tcg-aarch64: Use adrp in tcg_out_movi
Loading an qemu pointer as an immediate happens often.  E.g.

- exit_tb $0x7fa8140013
+ exit_tb $0x7f81ee0013
...
- :  d2800260        mov     x0, #0x13
- :  f2b50280        movk    x0, #0xa814, lsl #16
- :  f2c00fe0        movk    x0, #0x7f, lsl #32
+ :  90ff1000        adrp    x0, 0x7f81ee0000
+ :  91004c00        add     x0, x0, #0x13

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:58 -04:00
Richard Henderson
d8918df577 tcg-aarch64: Special case small constants in tcg_out_movi
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:58 -04:00
Richard Henderson
4ec4f0bd56 tcg-aarch64: Use ORRI in tcg_out_movi
The subset of logical immediates that we support is quite quick to test,
and such constants are quite common to want to load.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:58 -04:00
Richard Henderson
dfeb5fe770 tcg-aarch64: Use MOVN in tcg_out_movi
When profitable, initialize the register with MOVN instead of MOVZ,
before setting the remaining lanes with MOVK.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:58 -04:00
Richard Henderson
929f8b5550 tcg-aarch64: Use TCGType and TCGMemOp constants
Rather than raw constants that could mean anything.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:58 -04:00
Richard Henderson
8bf56493f1 tcg-aarch64: Use intptr_t apropriately
As opposed to tcg_target_long.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:58 -04:00
Richard Henderson
661f7fa4b0 tcg-aarch64: Properly detect SIGSEGV writes
Since the kernel doesn't pass any info on the reason for the fault,
disassemble the instruction to detect a store.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-04-16 12:12:32 -04:00
486 changed files with 14467 additions and 8138 deletions

18
.gitignore vendored
View File

@@ -18,8 +18,8 @@
/*-darwin-user /*-darwin-user
/*-linux-user /*-linux-user
/*-bsd-user /*-bsd-user
libdis* /libdis*
libuser /libuser
/linux-headers/asm /linux-headers/asm
/qga/qapi-generated /qga/qapi-generated
/qapi-generated /qapi-generated
@@ -49,19 +49,9 @@ libuser
/qemu-monitor.texi /qemu-monitor.texi
/qmp-commands.txt /qmp-commands.txt
/vscclient /vscclient
/test-bitops
/test-coroutine
/test-int128
/test-opts-visitor
/test-qmp-input-visitor
/test-qmp-output-visitor
/test-string-input-visitor
/test-string-output-visitor
/test-visitor-serialization
/fsdev/virtfs-proxy-helper /fsdev/virtfs-proxy-helper
/fsdev/virtfs-proxy-helper.1 /fsdev/virtfs-proxy-helper.1
/fsdev/virtfs-proxy-helper.pod /fsdev/virtfs-proxy-helper.pod
/.gdbinit
*.a *.a
*.aux *.aux
*.cp *.cp
@@ -90,12 +80,8 @@ libuser
*.pc *.pc
.libs .libs
.sdk .sdk
*.swp
*.orig
.pc
*.gcda *.gcda
*.gcno *.gcno
patches
/pc-bios/bios-pq/status /pc-bios/bios-pq/status
/pc-bios/vgabios-pq/status /pc-bios/vgabios-pq/status
/pc-bios/optionrom/linuxboot.asm /pc-bios/optionrom/linuxboot.asm

View File

@@ -52,6 +52,13 @@ General Project Administration
------------------------------ ------------------------------
M: Anthony Liguori <aliguori@amazon.com> M: Anthony Liguori <aliguori@amazon.com>
Responsible Disclosure, Reporting Security Issues
------------------------------
W: http://wiki.qemu.org/SecurityProcess
M: Michael S. Tsirkin <mst@redhat.com>
M: Anthony Liguori <aliguori@amazon.com>
L: secalert@redhat.com
Guest CPU cores (TCG): Guest CPU cores (TCG):
---------------------- ----------------------
Alpha Alpha
@@ -601,6 +608,7 @@ USB
M: Gerd Hoffmann <kraxel@redhat.com> M: Gerd Hoffmann <kraxel@redhat.com>
S: Maintained S: Maintained
F: hw/usb/* F: hw/usb/*
F: tests/usb-hcd-ehci-test.c
VFIO VFIO
M: Alex Williamson <alex.williamson@redhat.com> M: Alex Williamson <alex.williamson@redhat.com>
@@ -666,6 +674,9 @@ M: Gerd Hoffmann <kraxel@redhat.com>
S: Maintained S: Maintained
F: audio/ F: audio/
F: hw/audio/ F: hw/audio/
F: tests/ac97-test.c
F: tests/es1370-test.c
F: tests/intel-hda-test.c
Block Block
M: Kevin Wolf <kwolf@redhat.com> M: Kevin Wolf <kwolf@redhat.com>
@@ -674,6 +685,8 @@ S: Supported
F: block* F: block*
F: block/ F: block/
F: hw/block/ F: hw/block/
F: qemu-img*
F: qemu-io*
T: git git://repo.or.cz/qemu/kevin.git block T: git git://repo.or.cz/qemu/kevin.git block
T: git git://github.com/stefanha/qemu.git block T: git git://github.com/stefanha/qemu.git block
@@ -778,6 +791,17 @@ S: Supported
F: qapi-schema.json F: qapi-schema.json
T: git git://repo.or.cz/qemu/qmp-unstable.git queue/qmp T: git git://repo.or.cz/qemu/qmp-unstable.git queue/qmp
QOM
M: Anthony Liguori <aliguori@amazon.com>
M: Andreas Färber <afaerber@suse.de>
S: Supported
T: git git://github.com/afaerber/qemu-cpu.git qom-next
F: include/qom/
X: include/qom/cpu.h
F: qom/
X: qom/cpu.c
F: tests/qom-test.c
QMP QMP
M: Luiz Capitulino <lcapitulino@redhat.com> M: Luiz Capitulino <lcapitulino@redhat.com>
S: Maintained S: Maintained

View File

@@ -148,10 +148,6 @@ endif
all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
config-host.h: config-host.h-timestamp config-host.h: config-host.h-timestamp
config-host.h-timestamp: config-host.mak config-host.h-timestamp: config-host.mak
qemu-options.def: $(SRC_PATH)/qemu-options.hx qemu-options.def: $(SRC_PATH)/qemu-options.hx
@@ -195,8 +191,6 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES) recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h | $(BUILD_DIR)/version.lo $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h | $(BUILD_DIR)/version.lo
$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.o") $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.o")
$(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h $(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h
@@ -238,23 +232,35 @@ qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
$(gen-out-type) -o qga/qapi-generated -p "qga-" -i $<, \
" GEN $@")
qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
$(gen-out-type) -o qga/qapi-generated -p "qga-" -i $<, \
" GEN $@")
qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
$(gen-out-type) -o qga/qapi-generated -p "qga-" -i $<, \
" GEN $@")
qapi-types.c qapi-types.h :\ qapi-types.c qapi-types.h :\
$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." -b < $<, " GEN $@") $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
$(gen-out-type) -o "." -b -i $<, \
" GEN $@")
qapi-visit.c qapi-visit.h :\ qapi-visit.c qapi-visit.h :\
$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." -b < $<, " GEN $@") $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
$(gen-out-type) -o "." -b -i $<, \
" GEN $@")
qmp-commands.h qmp-marshal.c :\ qmp-commands.h qmp-marshal.c :\
$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
$(gen-out-type) -o "." -m -i $<, \
" GEN $@")
QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
@@ -372,17 +378,25 @@ install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig \
install-datadir install-localstatedir install-datadir install-localstatedir
$(INSTALL_DIR) "$(DESTDIR)$(bindir)" $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
ifneq ($(TOOLS),) ifneq ($(TOOLS),)
$(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)" $(INSTALL_PROG) $(TOOLS) "$(DESTDIR)$(bindir)"
ifneq ($(STRIP),)
$(STRIP) $(TOOLS:%="$(DESTDIR)$(bindir)/%")
endif
endif endif
ifneq ($(CONFIG_MODULES),) ifneq ($(CONFIG_MODULES),)
$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)" $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \ for s in $(modules-m:.mo=$(DSOSUF)); do \
$(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \ t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
$(INSTALL_LIB) $$s "$$t"; \
test -z "$(STRIP)" || $(STRIP) "$$t"; \
done done
endif endif
ifneq ($(HELPERS-y),) ifneq ($(HELPERS-y),)
$(INSTALL_DIR) "$(DESTDIR)$(libexecdir)" $(INSTALL_DIR) "$(DESTDIR)$(libexecdir)"
$(INSTALL_PROG) $(STRIP_OPT) $(HELPERS-y) "$(DESTDIR)$(libexecdir)" $(INSTALL_PROG) $(HELPERS-y) "$(DESTDIR)$(libexecdir)"
ifneq ($(STRIP),)
$(STRIP) $(HELPERS-y:%="$(DESTDIR)$(libexecdir)/%")
endif
endif endif
ifneq ($(BLOBS),) ifneq ($(BLOBS),)
set -e; for x in $(BLOBS); do \ set -e; for x in $(BLOBS); do \

View File

@@ -31,6 +31,8 @@ libcacard-y += libcacard/vcard_emul_nss.o
libcacard-y += libcacard/vcard_emul_type.o libcacard-y += libcacard/vcard_emul_type.o
libcacard-y += libcacard/card_7816.o libcacard-y += libcacard/card_7816.o
libcacard-y += libcacard/vcardt.o libcacard-y += libcacard/vcardt.o
libcacard/vcard_emul_nss.o-cflags := $(NSS_CFLAGS)
libcacard/vcard_emul_nss.o-libs := $(NSS_LIBS)
###################################################################### ######################################################################
# Target independent part of system emulation. The long term path is to # Target independent part of system emulation. The long term path is to
@@ -64,9 +66,11 @@ common-obj-y += hw/
common-obj-y += ui/ common-obj-y += ui/
common-obj-y += bt-host.o bt-vhci.o common-obj-y += bt-host.o bt-vhci.o
bt-host.o-cflags := $(BLUEZ_CFLAGS)
common-obj-y += dma-helpers.o common-obj-y += dma-helpers.o
common-obj-y += vl.o common-obj-y += vl.o
vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS)
common-obj-y += tpm.o common-obj-y += tpm.o
common-obj-$(CONFIG_SLIRP) += slirp/ common-obj-$(CONFIG_SLIRP) += slirp/

View File

@@ -16,19 +16,22 @@ QEMU_CFLAGS+=-I$(SRC_PATH)/include
ifdef CONFIG_USER_ONLY ifdef CONFIG_USER_ONLY
# user emulator name # user emulator name
QEMU_PROG=qemu-$(TARGET_NAME) QEMU_PROG=qemu-$(TARGET_NAME)
QEMU_PROG_BUILD = $(QEMU_PROG)
else else
# system emulator name # system emulator name
QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
ifneq (,$(findstring -mwindows,$(libs_softmmu))) ifneq (,$(findstring -mwindows,$(libs_softmmu)))
# Terminate program name with a 'w' because the linker builds a windows executable. # Terminate program name with a 'w' because the linker builds a windows executable.
QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF) QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
endif # windows executable $(QEMU_PROG): $(QEMU_PROGW)
QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF) $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG)," GEN $(TARGET_DIR)$(QEMU_PROG)")
QEMU_PROG_BUILD = $(QEMU_PROGW)
else
QEMU_PROG_BUILD = $(QEMU_PROG)
endif
endif endif
PROGS=$(QEMU_PROG) PROGS=$(QEMU_PROG) $(QEMU_PROGW)
ifdef QEMU_PROGW
PROGS+=$(QEMU_PROGW)
endif
STPFILES= STPFILES=
config-target.h: config-target.h-timestamp config-target.h: config-target.h-timestamp
@@ -120,8 +123,10 @@ obj-y += dump.o
LIBS+=$(libs_softmmu) LIBS+=$(libs_softmmu)
# xen support # xen support
obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o obj-$(CONFIG_XEN) += xen-common.o
obj-$(call lnot,$(CONFIG_XEN)) += xen-stub.o obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
obj-$(call lnot,$(CONFIG_XEN)) += xen-common-stub.o
obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
# Hardware support # Hardware support
ifeq ($(TARGET_NAME), sparc64) ifeq ($(TARGET_NAME), sparc64)
@@ -138,10 +143,7 @@ endif # CONFIG_SOFTMMU
%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
dummy := $(call unnest-vars,,obj-y) dummy := $(call unnest-vars,,obj-y)
all-obj-y := $(obj-y)
# we are making another call to unnest-vars with different vars, protect obj-y,
# it can be overriden in subdir Makefile.objs
obj-y-save := $(obj-y)
block-obj-y := block-obj-y :=
common-obj-y := common-obj-y :=
@@ -151,27 +153,16 @@ dummy := $(call unnest-vars,.., \
block-obj-m \ block-obj-m \
common-obj-y \ common-obj-y \
common-obj-m) common-obj-m)
all-obj-y += $(common-obj-y)
# Now restore obj-y
obj-y := $(obj-y-save)
all-obj-y = $(obj-y) $(common-obj-y)
all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
ifndef CONFIG_HAIKU ifndef CONFIG_HAIKU
LIBS+=-lm LIBS+=-lm
endif endif
ifdef QEMU_PROGW # build either PROG or PROGW
# The linker builds a windows executable. Make also a console executable. $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(QEMU_PROGW): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(call LINK,$^) $(call LINK,$^)
$(QEMU_PROG): $(QEMU_PROGW)
$(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG)," GEN $(TARGET_DIR)$(QEMU_PROG)")
else
$(QEMU_PROG): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(call LINK,$^)
endif
gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
$(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@") $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@")
@@ -192,9 +183,9 @@ endif
install: all install: all
ifneq ($(PROGS),) ifneq ($(PROGS),)
$(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)" $(INSTALL_PROG) $(PROGS) "$(DESTDIR)$(bindir)"
ifneq ($(STRIP),) ifneq ($(STRIP),)
$(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS)) $(STRIP) $(PROGS:%="$(DESTDIR)$(bindir)/%")
endif endif
endif endif
ifdef CONFIG_TRACE_SYSTEMTAP ifdef CONFIG_TRACE_SYSTEMTAP

View File

@@ -1 +1 @@
2.0.0 2.0.50

View File

@@ -45,6 +45,7 @@
#include "hw/audio/pcspk.h" #include "hw/audio/pcspk.h"
#include "migration/page_cache.h" #include "migration/page_cache.h"
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "qemu/error-report.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "trace.h" #include "trace.h"
#include "exec/cpu-all.h" #include "exec/cpu-all.h"
@@ -110,6 +111,8 @@ static bool mig_throttle_on;
static int dirty_rate_high_cnt; static int dirty_rate_high_cnt;
static void check_guest_throttling(void); static void check_guest_throttling(void);
static uint64_t bitmap_sync_count;
/***********************************************************/ /***********************************************************/
/* ram save/restore */ /* ram save/restore */
@@ -167,11 +170,8 @@ static struct {
/* Cache for XBZRLE, Protected by lock. */ /* Cache for XBZRLE, Protected by lock. */
PageCache *cache; PageCache *cache;
QemuMutex lock; QemuMutex lock;
} XBZRLE = { } XBZRLE;
.encoded_buf = NULL,
.current_buf = NULL,
.cache = NULL,
};
/* buffer used for XBZRLE decoding */ /* buffer used for XBZRLE decoding */
static uint8_t *xbzrle_decoded_buf; static uint8_t *xbzrle_decoded_buf;
@@ -187,41 +187,44 @@ static void XBZRLE_cache_unlock(void)
qemu_mutex_unlock(&XBZRLE.lock); qemu_mutex_unlock(&XBZRLE.lock);
} }
/*
* called from qmp_migrate_set_cache_size in main thread, possibly while
* a migration is in progress.
* A running migration maybe using the cache and might finish during this
* call, hence changes to the cache are protected by XBZRLE.lock().
*/
int64_t xbzrle_cache_resize(int64_t new_size) int64_t xbzrle_cache_resize(int64_t new_size)
{ {
PageCache *new_cache, *cache_to_free; PageCache *new_cache;
int64_t ret;
if (new_size < TARGET_PAGE_SIZE) { if (new_size < TARGET_PAGE_SIZE) {
return -1; return -1;
} }
/* no need to lock, the current thread holds qemu big lock */ XBZRLE_cache_lock();
if (XBZRLE.cache != NULL) { if (XBZRLE.cache != NULL) {
/* check XBZRLE.cache again later */
if (pow2floor(new_size) == migrate_xbzrle_cache_size()) { if (pow2floor(new_size) == migrate_xbzrle_cache_size()) {
return pow2floor(new_size); goto out_new_size;
} }
new_cache = cache_init(new_size / TARGET_PAGE_SIZE, new_cache = cache_init(new_size / TARGET_PAGE_SIZE,
TARGET_PAGE_SIZE); TARGET_PAGE_SIZE);
if (!new_cache) { if (!new_cache) {
DPRINTF("Error creating cache\n"); error_report("Error creating cache");
return -1; ret = -1;
goto out;
} }
XBZRLE_cache_lock(); cache_fini(XBZRLE.cache);
/* the XBZRLE.cache may have be destroyed, check it again */ XBZRLE.cache = new_cache;
if (XBZRLE.cache != NULL) {
cache_to_free = XBZRLE.cache;
XBZRLE.cache = new_cache;
} else {
cache_to_free = new_cache;
}
XBZRLE_cache_unlock();
cache_fini(cache_to_free);
} }
return pow2floor(new_size); out_new_size:
ret = pow2floor(new_size);
out:
XBZRLE_cache_unlock();
return ret;
} }
/* accounting for migration statistics */ /* accounting for migration statistics */
@@ -233,6 +236,7 @@ typedef struct AccountingInfo {
uint64_t xbzrle_bytes; uint64_t xbzrle_bytes;
uint64_t xbzrle_pages; uint64_t xbzrle_pages;
uint64_t xbzrle_cache_miss; uint64_t xbzrle_cache_miss;
double xbzrle_cache_miss_rate;
uint64_t xbzrle_overflows; uint64_t xbzrle_overflows;
} AccountingInfo; } AccountingInfo;
@@ -288,6 +292,11 @@ uint64_t xbzrle_mig_pages_cache_miss(void)
return acct_info.xbzrle_cache_miss; return acct_info.xbzrle_cache_miss;
} }
double xbzrle_mig_cache_miss_rate(void)
{
return acct_info.xbzrle_cache_miss_rate;
}
uint64_t xbzrle_mig_pages_overflow(void) uint64_t xbzrle_mig_pages_overflow(void)
{ {
return acct_info.xbzrle_overflows; return acct_info.xbzrle_overflows;
@@ -340,7 +349,7 @@ static void xbzrle_cache_zero_page(ram_addr_t current_addr)
#define ENCODING_FLAG_XBZRLE 0x1 #define ENCODING_FLAG_XBZRLE 0x1
static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
ram_addr_t current_addr, RAMBlock *block, ram_addr_t current_addr, RAMBlock *block,
ram_addr_t offset, int cont, bool last_stage) ram_addr_t offset, int cont, bool last_stage)
{ {
@@ -348,19 +357,23 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
uint8_t *prev_cached_page; uint8_t *prev_cached_page;
if (!cache_is_cached(XBZRLE.cache, current_addr)) { if (!cache_is_cached(XBZRLE.cache, current_addr)) {
acct_info.xbzrle_cache_miss++;
if (!last_stage) { if (!last_stage) {
if (cache_insert(XBZRLE.cache, current_addr, current_data) == -1) { if (cache_insert(XBZRLE.cache, current_addr, *current_data) == -1) {
return -1; return -1;
} else {
/* update *current_data when the page has been
inserted into cache */
*current_data = get_cached_data(XBZRLE.cache, current_addr);
} }
} }
acct_info.xbzrle_cache_miss++;
return -1; return -1;
} }
prev_cached_page = get_cached_data(XBZRLE.cache, current_addr); prev_cached_page = get_cached_data(XBZRLE.cache, current_addr);
/* save current buffer into memory */ /* save current buffer into memory */
memcpy(XBZRLE.current_buf, current_data, TARGET_PAGE_SIZE); memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
/* XBZRLE encoding (if there is no overflow) */ /* XBZRLE encoding (if there is no overflow) */
encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf, encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
@@ -373,7 +386,10 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
DPRINTF("Overflow\n"); DPRINTF("Overflow\n");
acct_info.xbzrle_overflows++; acct_info.xbzrle_overflows++;
/* update data in the cache */ /* update data in the cache */
memcpy(prev_cached_page, current_data, TARGET_PAGE_SIZE); if (!last_stage) {
memcpy(prev_cached_page, *current_data, TARGET_PAGE_SIZE);
*current_data = prev_cached_page;
}
return -1; return -1;
} }
@@ -479,6 +495,10 @@ static void migration_bitmap_sync(void)
static int64_t num_dirty_pages_period; static int64_t num_dirty_pages_period;
int64_t end_time; int64_t end_time;
int64_t bytes_xfer_now; int64_t bytes_xfer_now;
static uint64_t xbzrle_cache_miss_prev;
static uint64_t iterations_prev;
bitmap_sync_count++;
if (!bytes_xfer_prev) { if (!bytes_xfer_prev) {
bytes_xfer_prev = ram_bytes_transferred(); bytes_xfer_prev = ram_bytes_transferred();
@@ -520,11 +540,22 @@ static void migration_bitmap_sync(void)
} else { } else {
mig_throttle_on = false; mig_throttle_on = false;
} }
if (migrate_use_xbzrle()) {
if (iterations_prev != 0) {
acct_info.xbzrle_cache_miss_rate =
(double)(acct_info.xbzrle_cache_miss -
xbzrle_cache_miss_prev) /
(acct_info.iterations - iterations_prev);
}
iterations_prev = acct_info.iterations;
xbzrle_cache_miss_prev = acct_info.xbzrle_cache_miss;
}
s->dirty_pages_rate = num_dirty_pages_period * 1000 s->dirty_pages_rate = num_dirty_pages_period * 1000
/ (end_time - start_time); / (end_time - start_time);
s->dirty_bytes_rate = s->dirty_pages_rate * TARGET_PAGE_SIZE; s->dirty_bytes_rate = s->dirty_pages_rate * TARGET_PAGE_SIZE;
start_time = end_time; start_time = end_time;
num_dirty_pages_period = 0; num_dirty_pages_period = 0;
s->dirty_sync_count = bitmap_sync_count;
} }
} }
@@ -598,15 +629,9 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
*/ */
xbzrle_cache_zero_page(current_addr); xbzrle_cache_zero_page(current_addr);
} else if (!ram_bulk_stage && migrate_use_xbzrle()) { } else if (!ram_bulk_stage && migrate_use_xbzrle()) {
bytes_sent = save_xbzrle_page(f, p, current_addr, block, bytes_sent = save_xbzrle_page(f, &p, current_addr, block,
offset, cont, last_stage); offset, cont, last_stage);
if (!last_stage) { if (!last_stage) {
/* We must send exactly what's in the xbzrle cache
* even if the page wasn't xbzrle compressed, so that
* it's right next time.
*/
p = get_cached_data(XBZRLE.cache, current_addr);
/* Can't send this cached data async, since the cache page /* Can't send this cached data async, since the cache page
* might get updated before it gets to the wire * might get updated before it gets to the wire
*/ */
@@ -726,37 +751,34 @@ static void reset_ram_globals(void)
static int ram_save_setup(QEMUFile *f, void *opaque) static int ram_save_setup(QEMUFile *f, void *opaque)
{ {
RAMBlock *block; RAMBlock *block;
int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS; int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */
migration_bitmap = bitmap_new(ram_pages);
bitmap_set(migration_bitmap, 0, ram_pages);
migration_dirty_pages = ram_pages;
mig_throttle_on = false; mig_throttle_on = false;
dirty_rate_high_cnt = 0; dirty_rate_high_cnt = 0;
bitmap_sync_count = 0;
if (migrate_use_xbzrle()) { if (migrate_use_xbzrle()) {
qemu_mutex_lock_iothread(); XBZRLE_cache_lock();
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() / XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
TARGET_PAGE_SIZE, TARGET_PAGE_SIZE,
TARGET_PAGE_SIZE); TARGET_PAGE_SIZE);
if (!XBZRLE.cache) { if (!XBZRLE.cache) {
qemu_mutex_unlock_iothread(); XBZRLE_cache_unlock();
DPRINTF("Error creating cache\n"); error_report("Error creating cache");
return -1; return -1;
} }
qemu_mutex_init(&XBZRLE.lock); XBZRLE_cache_unlock();
qemu_mutex_unlock_iothread();
/* We prefer not to abort if there is no memory */ /* We prefer not to abort if there is no memory */
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE); XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
if (!XBZRLE.encoded_buf) { if (!XBZRLE.encoded_buf) {
DPRINTF("Error allocating encoded_buf\n"); error_report("Error allocating encoded_buf");
return -1; return -1;
} }
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE); XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);
if (!XBZRLE.current_buf) { if (!XBZRLE.current_buf) {
DPRINTF("Error allocating current_buf\n"); error_report("Error allocating current_buf");
g_free(XBZRLE.encoded_buf); g_free(XBZRLE.encoded_buf);
XBZRLE.encoded_buf = NULL; XBZRLE.encoded_buf = NULL;
return -1; return -1;
@@ -770,6 +792,22 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
bytes_transferred = 0; bytes_transferred = 0;
reset_ram_globals(); reset_ram_globals();
ram_bitmap_pages = last_ram_offset() >> TARGET_PAGE_BITS;
migration_bitmap = bitmap_new(ram_bitmap_pages);
bitmap_set(migration_bitmap, 0, ram_bitmap_pages);
/*
* Count the total number of pages used by ram blocks not including any
* gaps due to alignment or unplugs.
*/
migration_dirty_pages = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
uint64_t block_pages;
block_pages = block->length >> TARGET_PAGE_BITS;
migration_dirty_pages += block_pages;
}
memory_global_dirty_log_start(); memory_global_dirty_log_start();
migration_bitmap_sync(); migration_bitmap_sync();
qemu_mutex_unlock_iothread(); qemu_mutex_unlock_iothread();
@@ -997,8 +1035,9 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
seq_iter++; seq_iter++;
if (version_id < 4 || version_id > 4) { if (version_id != 4) {
return -EINVAL; ret = -EINVAL;
goto done;
} }
do { do {
@@ -1008,44 +1047,42 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
addr &= TARGET_PAGE_MASK; addr &= TARGET_PAGE_MASK;
if (flags & RAM_SAVE_FLAG_MEM_SIZE) { if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
if (version_id == 4) { /* Synchronize RAM block list */
/* Synchronize RAM block list */ char id[256];
char id[256]; ram_addr_t length;
ram_addr_t length; ram_addr_t total_ram_bytes = addr;
ram_addr_t total_ram_bytes = addr;
while (total_ram_bytes) { while (total_ram_bytes) {
RAMBlock *block; RAMBlock *block;
uint8_t len; uint8_t len;
len = qemu_get_byte(f); len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)id, len); qemu_get_buffer(f, (uint8_t *)id, len);
id[len] = 0; id[len] = 0;
length = qemu_get_be64(f); length = qemu_get_be64(f);
QTAILQ_FOREACH(block, &ram_list.blocks, next) { QTAILQ_FOREACH(block, &ram_list.blocks, next) {
if (!strncmp(id, block->idstr, sizeof(id))) { if (!strncmp(id, block->idstr, sizeof(id))) {
if (block->length != length) { if (block->length != length) {
fprintf(stderr, fprintf(stderr,
"Length mismatch: %s: " RAM_ADDR_FMT "Length mismatch: %s: " RAM_ADDR_FMT
" in != " RAM_ADDR_FMT "\n", id, length, " in != " RAM_ADDR_FMT "\n", id, length,
block->length); block->length);
ret = -EINVAL; ret = -EINVAL;
goto done; goto done;
}
break;
} }
break;
} }
if (!block) {
fprintf(stderr, "Unknown ramblock \"%s\", cannot "
"accept migration\n", id);
ret = -EINVAL;
goto done;
}
total_ram_bytes -= length;
} }
if (!block) {
fprintf(stderr, "Unknown ramblock \"%s\", cannot "
"accept migration\n", id);
ret = -EINVAL;
goto done;
}
total_ram_bytes -= length;
} }
} }
@@ -1055,7 +1092,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
host = host_from_stream_offset(f, addr, flags); host = host_from_stream_offset(f, addr, flags);
if (!host) { if (!host) {
return -EINVAL; ret = -EINVAL;
goto done;
} }
ch = qemu_get_byte(f); ch = qemu_get_byte(f);
@@ -1065,14 +1103,16 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
host = host_from_stream_offset(f, addr, flags); host = host_from_stream_offset(f, addr, flags);
if (!host) { if (!host) {
return -EINVAL; ret = -EINVAL;
goto done;
} }
qemu_get_buffer(f, host, TARGET_PAGE_SIZE); qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
} else if (flags & RAM_SAVE_FLAG_XBZRLE) { } else if (flags & RAM_SAVE_FLAG_XBZRLE) {
void *host = host_from_stream_offset(f, addr, flags); void *host = host_from_stream_offset(f, addr, flags);
if (!host) { if (!host) {
return -EINVAL; ret = -EINVAL;
goto done;
} }
if (load_xbzrle(f, addr, host) < 0) { if (load_xbzrle(f, addr, host) < 0) {
@@ -1095,7 +1135,7 @@ done:
return ret; return ret;
} }
SaveVMHandlers savevm_ram_handlers = { static SaveVMHandlers savevm_ram_handlers = {
.save_live_setup = ram_save_setup, .save_live_setup = ram_save_setup,
.save_live_iterate = ram_save_iterate, .save_live_iterate = ram_save_iterate,
.save_live_complete = ram_save_complete, .save_live_complete = ram_save_complete,
@@ -1104,6 +1144,12 @@ SaveVMHandlers savevm_ram_handlers = {
.cancel = ram_migration_cancel, .cancel = ram_migration_cancel,
}; };
void ram_mig_init(void)
{
qemu_mutex_init(&XBZRLE.lock);
register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL);
}
struct soundhw { struct soundhw {
const char *name; const char *name;
const char *descr; const char *descr;

View File

@@ -14,4 +14,4 @@ common-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
common-obj-y += wavcapture.o common-obj-y += wavcapture.o
$(obj)/audio.o $(obj)/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS) $(obj)/audio.o $(obj)/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
$(obj)/sdlaudio.o: QEMU_CFLAGS += $(SDL_CFLAGS) sdlaudio.o-cflags := $(SDL_CFLAGS)

View File

@@ -3,6 +3,6 @@ common-obj-$(CONFIG_POSIX) += rng-random.o
common-obj-y += msmouse.o common-obj-y += msmouse.o
common-obj-$(CONFIG_BRLAPI) += baum.o common-obj-$(CONFIG_BRLAPI) += baum.o
$(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) baum.o-cflags := $(SDL_CFLAGS)
common-obj-$(CONFIG_TPM) += tpm.o common-obj-$(CONFIG_TPM) += tpm.o

View File

@@ -50,6 +50,7 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
{ {
RngBackend *s = RNG_BACKEND(obj); RngBackend *s = RNG_BACKEND(obj);
RngBackendClass *k = RNG_BACKEND_GET_CLASS(s); RngBackendClass *k = RNG_BACKEND_GET_CLASS(s);
Error *local_err = NULL;
if (value == s->opened) { if (value == s->opened) {
return; return;
@@ -61,12 +62,14 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
} }
if (k->opened) { if (k->opened) {
k->opened(s, errp); k->opened(s, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
} }
if (!error_is_set(errp)) { s->opened = true;
s->opened = value;
}
} }
static void rng_backend_init(Object *obj) static void rng_backend_init(Object *obj)

View File

@@ -112,6 +112,7 @@ static void tpm_backend_prop_set_opened(Object *obj, bool value, Error **errp)
{ {
TPMBackend *s = TPM_BACKEND(obj); TPMBackend *s = TPM_BACKEND(obj);
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s); TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
Error *local_err = NULL;
if (value == s->opened) { if (value == s->opened) {
return; return;
@@ -123,12 +124,14 @@ static void tpm_backend_prop_set_opened(Object *obj, bool value, Error **errp)
} }
if (k->opened) { if (k->opened) {
k->opened(s, errp); k->opened(s, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
} }
if (!error_is_set(errp)) { s->opened = true;
s->opened = value;
}
} }
static void tpm_backend_instance_init(Object *obj) static void tpm_backend_instance_init(Object *obj)

View File

@@ -310,13 +310,28 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds)
/* Called with iothread lock taken. */ /* Called with iothread lock taken. */
static void set_dirty_tracking(void) static int set_dirty_tracking(void)
{ {
BlkMigDevState *bmds; BlkMigDevState *bmds;
int ret;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE); bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE,
NULL);
if (!bmds->dirty_bitmap) {
ret = -errno;
goto fail;
}
} }
return 0;
fail:
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (bmds->dirty_bitmap) {
bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap);
}
}
return ret;
} }
static void unset_dirty_tracking(void) static void unset_dirty_tracking(void)
@@ -611,10 +626,17 @@ static int block_save_setup(QEMUFile *f, void *opaque)
block_mig_state.submitted, block_mig_state.transferred); block_mig_state.submitted, block_mig_state.transferred);
qemu_mutex_lock_iothread(); qemu_mutex_lock_iothread();
init_blk_migration(f);
/* start track dirty blocks */ /* start track dirty blocks */
set_dirty_tracking(); ret = set_dirty_tracking();
if (ret) {
qemu_mutex_unlock_iothread();
return ret;
}
init_blk_migration(f);
qemu_mutex_unlock_iothread(); qemu_mutex_unlock_iothread();
ret = flush_blks(f); ret = flush_blks(f);

228
block.c
View File

@@ -332,10 +332,21 @@ void bdrv_register(BlockDriver *bdrv)
} }
/* create a new block device (by default it is empty) */ /* create a new block device (by default it is empty) */
BlockDriverState *bdrv_new(const char *device_name) BlockDriverState *bdrv_new(const char *device_name, Error **errp)
{ {
BlockDriverState *bs; BlockDriverState *bs;
if (bdrv_find(device_name)) {
error_setg(errp, "Device with id '%s' already exists",
device_name);
return NULL;
}
if (bdrv_find_node(device_name)) {
error_setg(errp, "Device with node-name '%s' already exists",
device_name);
return NULL;
}
bs = g_malloc0(sizeof(BlockDriverState)); bs = g_malloc0(sizeof(BlockDriverState));
QLIST_INIT(&bs->dirty_bitmaps); QLIST_INIT(&bs->dirty_bitmaps);
pstrcpy(bs->device_name, sizeof(bs->device_name), device_name); pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
@@ -763,15 +774,54 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs)
bs->copy_on_read--; bs->copy_on_read--;
} }
/*
* Returns the flags that a temporary snapshot should get, based on the
* originally requested flags (the originally requested image will have flags
* like a backing file)
*/
static int bdrv_temp_snapshot_flags(int flags)
{
return (flags & ~BDRV_O_SNAPSHOT) | BDRV_O_TEMPORARY;
}
/*
* Returns the flags that bs->file should get, based on the given flags for
* the parent BDS
*/
static int bdrv_inherited_flags(int flags)
{
/* Enable protocol handling, disable format probing for bs->file */
flags |= BDRV_O_PROTOCOL;
/* Our block drivers take care to send flushes and respect unmap policy,
* so we can enable both unconditionally on lower layers. */
flags |= BDRV_O_CACHE_WB | BDRV_O_UNMAP;
/* Clear flags that only apply to the top layer */
flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_READ);
return flags;
}
/*
* Returns the flags that bs->backing_hd should get, based on the given flags
* for the parent BDS
*/
static int bdrv_backing_flags(int flags)
{
/* backing files always opened read-only */
flags &= ~(BDRV_O_RDWR | BDRV_O_COPY_ON_READ);
/* snapshot=on is handled on the top layer */
flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_TEMPORARY);
return flags;
}
static int bdrv_open_flags(BlockDriverState *bs, int flags) static int bdrv_open_flags(BlockDriverState *bs, int flags)
{ {
int open_flags = flags | BDRV_O_CACHE_WB; int open_flags = flags | BDRV_O_CACHE_WB;
/* The backing file of a temporary snapshot is read-only */
if (flags & BDRV_O_SNAPSHOT) {
open_flags &= ~BDRV_O_RDWR;
}
/* /*
* Clear flags that are internal to the block layer before opening the * Clear flags that are internal to the block layer before opening the
* image. * image.
@@ -781,45 +831,43 @@ static int bdrv_open_flags(BlockDriverState *bs, int flags)
/* /*
* Snapshots should be writable. * Snapshots should be writable.
*/ */
if (bs->is_temporary) { if (flags & BDRV_O_TEMPORARY) {
open_flags |= BDRV_O_RDWR; open_flags |= BDRV_O_RDWR;
} }
return open_flags; return open_flags;
} }
static int bdrv_assign_node_name(BlockDriverState *bs, static void bdrv_assign_node_name(BlockDriverState *bs,
const char *node_name, const char *node_name,
Error **errp) Error **errp)
{ {
if (!node_name) { if (!node_name) {
return 0; return;
} }
/* empty string node name is invalid */ /* empty string node name is invalid */
if (node_name[0] == '\0') { if (node_name[0] == '\0') {
error_setg(errp, "Empty node name"); error_setg(errp, "Empty node name");
return -EINVAL; return;
} }
/* takes care of avoiding namespaces collisions */ /* takes care of avoiding namespaces collisions */
if (bdrv_find(node_name)) { if (bdrv_find(node_name)) {
error_setg(errp, "node-name=%s is conflicting with a device id", error_setg(errp, "node-name=%s is conflicting with a device id",
node_name); node_name);
return -EINVAL; return;
} }
/* takes care of avoiding duplicates node names */ /* takes care of avoiding duplicates node names */
if (bdrv_find_node(node_name)) { if (bdrv_find_node(node_name)) {
error_setg(errp, "Duplicate node name"); error_setg(errp, "Duplicate node name");
return -EINVAL; return;
} }
/* copy node name into the bs and insert it into the graph list */ /* copy node name into the bs and insert it into the graph list */
pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
return 0;
} }
/* /*
@@ -854,9 +902,10 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name); trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
node_name = qdict_get_try_str(options, "node-name"); node_name = qdict_get_try_str(options, "node-name");
ret = bdrv_assign_node_name(bs, node_name, errp); bdrv_assign_node_name(bs, node_name, &local_err);
if (ret < 0) { if (local_err) {
return ret; error_propagate(errp, local_err);
return -EINVAL;
} }
qdict_del(options, "node-name"); qdict_del(options, "node-name");
@@ -941,13 +990,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
bdrv_refresh_limits(bs); bdrv_refresh_limits(bs);
assert(bdrv_opt_mem_align(bs) != 0); assert(bdrv_opt_mem_align(bs) != 0);
assert((bs->request_alignment != 0) || bs->sg); assert((bs->request_alignment != 0) || bs->sg);
#ifndef _WIN32
if (bs->is_temporary) {
assert(bs->filename[0] != '\0');
unlink(bs->filename);
}
#endif
return 0; return 0;
free_and_fail: free_and_fail:
@@ -1058,14 +1100,14 @@ fail:
*/ */
int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
{ {
char backing_filename[PATH_MAX]; char *backing_filename = g_malloc0(PATH_MAX);
int back_flags, ret; int ret = 0;
BlockDriver *back_drv = NULL; BlockDriver *back_drv = NULL;
Error *local_err = NULL; Error *local_err = NULL;
if (bs->backing_hd != NULL) { if (bs->backing_hd != NULL) {
QDECREF(options); QDECREF(options);
return 0; goto free_exit;
} }
/* NULL means an empty set of options */ /* NULL means an empty set of options */
@@ -1078,31 +1120,26 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
backing_filename[0] = '\0'; backing_filename[0] = '\0';
} else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) { } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) {
QDECREF(options); QDECREF(options);
return 0; goto free_exit;
} else { } else {
bdrv_get_full_backing_filename(bs, backing_filename, bdrv_get_full_backing_filename(bs, backing_filename, PATH_MAX);
sizeof(backing_filename));
} }
if (bs->backing_format[0] != '\0') { if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format); back_drv = bdrv_find_format(bs->backing_format);
} }
/* backing files always opened read-only */
back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT |
BDRV_O_COPY_ON_READ);
assert(bs->backing_hd == NULL); assert(bs->backing_hd == NULL);
ret = bdrv_open(&bs->backing_hd, ret = bdrv_open(&bs->backing_hd,
*backing_filename ? backing_filename : NULL, NULL, options, *backing_filename ? backing_filename : NULL, NULL, options,
back_flags, back_drv, &local_err); bdrv_backing_flags(bs->open_flags), back_drv, &local_err);
if (ret < 0) { if (ret < 0) {
bs->backing_hd = NULL; bs->backing_hd = NULL;
bs->open_flags |= BDRV_O_NO_BACKING; bs->open_flags |= BDRV_O_NO_BACKING;
error_setg(errp, "Could not open backing file: %s", error_setg(errp, "Could not open backing file: %s",
error_get_pretty(local_err)); error_get_pretty(local_err));
error_free(local_err); error_free(local_err);
return ret; goto free_exit;
} }
if (bs->backing_hd->file) { if (bs->backing_hd->file) {
@@ -1113,7 +1150,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
/* Recalculate the BlockLimits with the backing file */ /* Recalculate the BlockLimits with the backing file */
bdrv_refresh_limits(bs); bdrv_refresh_limits(bs);
return 0; free_exit:
g_free(backing_filename);
return ret;
} }
/* /*
@@ -1167,11 +1206,10 @@ done:
return ret; return ret;
} }
void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp) void bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
{ {
/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */ /* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
char tmp_filename[PATH_MAX + 1]; char *tmp_filename = g_malloc0(PATH_MAX + 1);
int64_t total_size; int64_t total_size;
BlockDriver *bdrv_qcow2; BlockDriver *bdrv_qcow2;
QEMUOptionParameter *create_options; QEMUOptionParameter *create_options;
@@ -1187,15 +1225,15 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp)
total_size = bdrv_getlength(bs); total_size = bdrv_getlength(bs);
if (total_size < 0) { if (total_size < 0) {
error_setg_errno(errp, -total_size, "Could not get image size"); error_setg_errno(errp, -total_size, "Could not get image size");
return; goto out;
} }
total_size &= BDRV_SECTOR_MASK; total_size &= BDRV_SECTOR_MASK;
/* Create the temporary image */ /* Create the temporary image */
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename)); ret = get_tmp_filename(tmp_filename, PATH_MAX + 1);
if (ret < 0) { if (ret < 0) {
error_setg_errno(errp, -ret, "Could not get temporary filename"); error_setg_errno(errp, -ret, "Could not get temporary filename");
return; goto out;
} }
bdrv_qcow2 = bdrv_find_format("qcow2"); bdrv_qcow2 = bdrv_find_format("qcow2");
@@ -1211,7 +1249,7 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp)
"'%s': %s", tmp_filename, "'%s': %s", tmp_filename,
error_get_pretty(local_err)); error_get_pretty(local_err));
error_free(local_err); error_free(local_err);
return; goto out;
} }
/* Prepare a new options QDict for the temporary file */ /* Prepare a new options QDict for the temporary file */
@@ -1221,17 +1259,19 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp)
qdict_put(snapshot_options, "file.filename", qdict_put(snapshot_options, "file.filename",
qstring_from_str(tmp_filename)); qstring_from_str(tmp_filename));
bs_snapshot = bdrv_new(""); bs_snapshot = bdrv_new("", &error_abort);
bs_snapshot->is_temporary = 1;
ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options, ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options,
bs->open_flags & ~BDRV_O_SNAPSHOT, bdrv_qcow2, &local_err); flags, bdrv_qcow2, &local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
return; goto out;
} }
bdrv_append(bs_snapshot, bs); bdrv_append(bs_snapshot, bs);
out:
g_free(tmp_filename);
} }
/* /*
@@ -1257,6 +1297,7 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
BlockDriverState *file = NULL, *bs; BlockDriverState *file = NULL, *bs;
const char *drvname; const char *drvname;
Error *local_err = NULL; Error *local_err = NULL;
int snapshot_flags = 0;
assert(pbs); assert(pbs);
@@ -1288,7 +1329,7 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
if (*pbs) { if (*pbs) {
bs = *pbs; bs = *pbs;
} else { } else {
bs = bdrv_new(""); bs = bdrv_new("", &error_abort);
} }
/* NULL means an empty set of options */ /* NULL means an empty set of options */
@@ -1317,13 +1358,17 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
if (flags & BDRV_O_RDWR) { if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR; flags |= BDRV_O_ALLOW_RDWR;
} }
if (flags & BDRV_O_SNAPSHOT) {
snapshot_flags = bdrv_temp_snapshot_flags(flags);
flags = bdrv_backing_flags(flags);
}
assert(file == NULL); assert(file == NULL);
ret = bdrv_open_image(&file, filename, options, "file", ret = bdrv_open_image(&file, filename, options, "file",
bdrv_open_flags(bs, flags | BDRV_O_UNMAP) | bdrv_inherited_flags(flags),
BDRV_O_PROTOCOL, true, &local_err); true, &local_err);
if (ret < 0) { if (ret < 0) {
goto unlink_and_fail; goto fail;
} }
/* Find the right image format driver */ /* Find the right image format driver */
@@ -1334,7 +1379,7 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
if (!drv) { if (!drv) {
error_setg(errp, "Invalid driver: '%s'", drvname); error_setg(errp, "Invalid driver: '%s'", drvname);
ret = -EINVAL; ret = -EINVAL;
goto unlink_and_fail; goto fail;
} }
} }
@@ -1344,18 +1389,18 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
} else { } else {
error_setg(errp, "Must specify either driver or file"); error_setg(errp, "Must specify either driver or file");
ret = -EINVAL; ret = -EINVAL;
goto unlink_and_fail; goto fail;
} }
} }
if (!drv) { if (!drv) {
goto unlink_and_fail; goto fail;
} }
/* Open the image */ /* Open the image */
ret = bdrv_open_common(bs, file, options, flags, drv, &local_err); ret = bdrv_open_common(bs, file, options, flags, drv, &local_err);
if (ret < 0) { if (ret < 0) {
goto unlink_and_fail; goto fail;
} }
if (file && (bs->file != file)) { if (file && (bs->file != file)) {
@@ -1376,8 +1421,8 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
/* For snapshot=on, create a temporary qcow2 overlay. bs points to the /* For snapshot=on, create a temporary qcow2 overlay. bs points to the
* temporary snapshot afterwards. */ * temporary snapshot afterwards. */
if (flags & BDRV_O_SNAPSHOT) { if (snapshot_flags) {
bdrv_append_temp_snapshot(bs, &local_err); bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
if (local_err) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
goto close_and_fail; goto close_and_fail;
@@ -1417,14 +1462,10 @@ done:
*pbs = bs; *pbs = bs;
return 0; return 0;
unlink_and_fail: fail:
if (file != NULL) { if (file != NULL) {
bdrv_unref(file); bdrv_unref(file);
} }
if (bs->is_temporary) {
unlink(filename);
}
fail:
QDECREF(bs->options); QDECREF(bs->options);
QDECREF(options); QDECREF(options);
bs->options = NULL; bs->options = NULL;
@@ -1488,8 +1529,11 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
QSIMPLEQ_INIT(bs_queue); QSIMPLEQ_INIT(bs_queue);
} }
/* bdrv_open() masks this flag out */
flags &= ~BDRV_O_PROTOCOL;
if (bs->file) { if (bs->file) {
bdrv_reopen_queue(bs_queue, bs->file, flags); bdrv_reopen_queue(bs_queue, bs->file, bdrv_inherited_flags(flags));
} }
bs_entry = g_new0(BlockReopenQueueEntry, 1); bs_entry = g_new0(BlockReopenQueueEntry, 1);
@@ -1704,11 +1748,6 @@ void bdrv_close(BlockDriverState *bs)
} }
bs->drv->bdrv_close(bs); bs->drv->bdrv_close(bs);
g_free(bs->opaque); g_free(bs->opaque);
#ifdef _WIN32
if (bs->is_temporary) {
unlink(bs->filename);
}
#endif
bs->opaque = NULL; bs->opaque = NULL;
bs->drv = NULL; bs->drv = NULL;
bs->copy_on_read = 0; bs->copy_on_read = 0;
@@ -1832,7 +1871,6 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest,
BlockDriverState *bs_src) BlockDriverState *bs_src)
{ {
/* move some fields that need to stay attached to the device */ /* move some fields that need to stay attached to the device */
bs_dest->open_flags = bs_src->open_flags;
/* dev info */ /* dev info */
bs_dest->dev_ops = bs_src->dev_ops; bs_dest->dev_ops = bs_src->dev_ops;
@@ -2581,6 +2619,10 @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
{ {
int64_t len; int64_t len;
if (size > INT_MAX) {
return -EIO;
}
if (!bdrv_is_inserted(bs)) if (!bdrv_is_inserted(bs))
return -ENOMEDIUM; return -ENOMEDIUM;
@@ -2601,7 +2643,7 @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num, static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
int nb_sectors) int nb_sectors)
{ {
if (nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) { if (nb_sectors < 0 || nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
return -EIO; return -EIO;
} }
@@ -2686,6 +2728,10 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
.iov_len = nb_sectors * BDRV_SECTOR_SIZE, .iov_len = nb_sectors * BDRV_SECTOR_SIZE,
}; };
if (nb_sectors < 0 || nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
return -EINVAL;
}
qemu_iovec_init_external(&qiov, &iov, 1); qemu_iovec_init_external(&qiov, &iov, 1);
return bdrv_prwv_co(bs, sector_num << BDRV_SECTOR_BITS, return bdrv_prwv_co(bs, sector_num << BDRV_SECTOR_BITS,
&qiov, is_write, flags); &qiov, is_write, flags);
@@ -2741,10 +2787,16 @@ int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
*/ */
int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags) int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags)
{ {
int64_t target_size = bdrv_getlength(bs) / BDRV_SECTOR_SIZE; int64_t target_size;
int64_t ret, nb_sectors, sector_num = 0; int64_t ret, nb_sectors, sector_num = 0;
int n; int n;
target_size = bdrv_getlength(bs);
if (target_size < 0) {
return target_size;
}
target_size /= BDRV_SECTOR_SIZE;
for (;;) { for (;;) {
nb_sectors = target_size - sector_num; nb_sectors = target_size - sector_num;
if (nb_sectors <= 0) { if (nb_sectors <= 0) {
@@ -3574,10 +3626,25 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
void *opaque) void *opaque)
{ {
BlockDriver *drv; BlockDriver *drv;
int count = 0;
const char **formats = NULL;
QLIST_FOREACH(drv, &bdrv_drivers, list) { QLIST_FOREACH(drv, &bdrv_drivers, list) {
it(opaque, drv->format_name); if (drv->format_name) {
bool found = false;
int i = count;
while (formats && i && !found) {
found = !strcmp(formats[--i], drv->format_name);
}
if (!found) {
formats = g_realloc(formats, (count + 1) * sizeof(char *));
formats[count++] = drv->format_name;
it(opaque, drv->format_name);
}
}
} }
g_free(formats);
} }
/* This function is to find block backend bs */ /* This function is to find block backend bs */
@@ -5096,7 +5163,8 @@ bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
return true; return true;
} }
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity) BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity,
Error **errp)
{ {
int64_t bitmap_size; int64_t bitmap_size;
BdrvDirtyBitmap *bitmap; BdrvDirtyBitmap *bitmap;
@@ -5105,7 +5173,13 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity)
granularity >>= BDRV_SECTOR_BITS; granularity >>= BDRV_SECTOR_BITS;
assert(granularity); assert(granularity);
bitmap_size = (bdrv_getlength(bs) >> BDRV_SECTOR_BITS); bitmap_size = bdrv_getlength(bs);
if (bitmap_size < 0) {
error_setg_errno(errp, -bitmap_size, "could not get length of device");
errno = -bitmap_size;
return NULL;
}
bitmap_size >>= BDRV_SECTOR_BITS;
bitmap = g_malloc0(sizeof(BdrvDirtyBitmap)); bitmap = g_malloc0(sizeof(BdrvDirtyBitmap));
bitmap->bitmap = hbitmap_alloc(bitmap_size, ffs(granularity) - 1); bitmap->bitmap = hbitmap_alloc(bitmap_size, ffs(granularity) - 1);
QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list); QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list);

View File

@@ -187,13 +187,14 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
uint64_t offset = sector_num * 512; uint64_t offset = sector_num * 512;
uint64_t extent_index, extent_offset, bitmap_offset; uint64_t extent_index, extent_offset, bitmap_offset;
char bitmap_entry; char bitmap_entry;
int ret;
// seek to sector // seek to sector
extent_index = offset / s->extent_size; extent_index = offset / s->extent_size;
extent_offset = (offset % s->extent_size) / 512; extent_offset = (offset % s->extent_size) / 512;
if (s->catalog_bitmap[extent_index] == 0xffffffff) { if (s->catalog_bitmap[extent_index] == 0xffffffff) {
return -1; /* not allocated */ return 0; /* not allocated */
} }
bitmap_offset = s->data_offset + bitmap_offset = s->data_offset +
@@ -201,13 +202,14 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
(s->extent_blocks + s->bitmap_blocks)); (s->extent_blocks + s->bitmap_blocks));
/* read in bitmap for current extent */ /* read in bitmap for current extent */
if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8), ret = bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8),
&bitmap_entry, 1) != 1) { &bitmap_entry, 1);
return -1; if (ret < 0) {
return ret;
} }
if (!((bitmap_entry >> (extent_offset % 8)) & 1)) { if (!((bitmap_entry >> (extent_offset % 8)) & 1)) {
return -1; /* not allocated */ return 0; /* not allocated */
} }
return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset)); return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
@@ -220,13 +222,16 @@ static int bochs_read(BlockDriverState *bs, int64_t sector_num,
while (nb_sectors > 0) { while (nb_sectors > 0) {
int64_t block_offset = seek_to_sector(bs, sector_num); int64_t block_offset = seek_to_sector(bs, sector_num);
if (block_offset >= 0) { if (block_offset < 0) {
return block_offset;
} else if (block_offset > 0) {
ret = bdrv_pread(bs->file, block_offset, buf, 512); ret = bdrv_pread(bs->file, block_offset, buf, 512);
if (ret != 512) { if (ret < 0) {
return -1; return ret;
} }
} else } else {
memset(buf, 0, 512); memset(buf, 0, 512);
}
nb_sectors--; nb_sectors--;
sector_num++; sector_num++;
buf += 512; buf += 512;

View File

@@ -72,7 +72,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
} }
s->block_size = be32_to_cpu(s->block_size); s->block_size = be32_to_cpu(s->block_size);
if (s->block_size % 512) { if (s->block_size % 512) {
error_setg(errp, "block_size %u must be a multiple of 512", error_setg(errp, "block_size %" PRIu32 " must be a multiple of 512",
s->block_size); s->block_size);
return -EINVAL; return -EINVAL;
} }
@@ -86,7 +86,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
* need a buffer this big. * need a buffer this big.
*/ */
if (s->block_size > MAX_BLOCK_SIZE) { if (s->block_size > MAX_BLOCK_SIZE) {
error_setg(errp, "block_size %u must be %u MB or less", error_setg(errp, "block_size %" PRIu32 " must be %u MB or less",
s->block_size, s->block_size,
MAX_BLOCK_SIZE / (1024 * 1024)); MAX_BLOCK_SIZE / (1024 * 1024));
return -EINVAL; return -EINVAL;
@@ -101,7 +101,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
/* read offsets */ /* read offsets */
if (s->n_blocks > (UINT32_MAX - 1) / sizeof(uint64_t)) { if (s->n_blocks > (UINT32_MAX - 1) / sizeof(uint64_t)) {
/* Prevent integer overflow */ /* Prevent integer overflow */
error_setg(errp, "n_blocks %u must be %zu or less", error_setg(errp, "n_blocks %" PRIu32 " must be %zu or less",
s->n_blocks, s->n_blocks,
(UINT32_MAX - 1) / sizeof(uint64_t)); (UINT32_MAX - 1) / sizeof(uint64_t));
return -EINVAL; return -EINVAL;
@@ -133,7 +133,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
if (s->offsets[i] < s->offsets[i - 1]) { if (s->offsets[i] < s->offsets[i - 1]) {
error_setg(errp, "offsets not monotonically increasing at " error_setg(errp, "offsets not monotonically increasing at "
"index %u, image file is corrupt", i); "index %" PRIu32 ", image file is corrupt", i);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} }
@@ -146,8 +146,8 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
* ridiculous s->compressed_block allocation. * ridiculous s->compressed_block allocation.
*/ */
if (size > 2 * MAX_BLOCK_SIZE) { if (size > 2 * MAX_BLOCK_SIZE) {
error_setg(errp, "invalid compressed block size at index %u, " error_setg(errp, "invalid compressed block size at index %" PRIu32
"image file is corrupt", i); ", image file is corrupt", i);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} }

View File

@@ -194,7 +194,7 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
if ((on_error == BLOCKDEV_ON_ERROR_STOP || if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
on_error == BLOCKDEV_ON_ERROR_ENOSPC) && on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) { !bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER_COMBINATION); error_setg(errp, "Invalid parameter combination");
return; return;
} }

View File

@@ -82,7 +82,7 @@ static int cow_open(BlockDriverState *bs, QDict *options, int flags,
if (be32_to_cpu(cow_header.version) != COW_VERSION) { if (be32_to_cpu(cow_header.version) != COW_VERSION) {
char version[64]; char version[64];
snprintf(version, sizeof(version), snprintf(version, sizeof(version),
"COW version %d", cow_header.version); "COW version %" PRIu32, cow_header.version);
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bs->device_name, "cow", version); bs->device_name, "cow", version);
ret = -ENOTSUP; ret = -ENOTSUP;

View File

@@ -71,6 +71,7 @@ typedef struct CURLState
struct BDRVCURLState *s; struct BDRVCURLState *s;
CURLAIOCB *acb[CURL_NUM_ACB]; CURLAIOCB *acb[CURL_NUM_ACB];
CURL *curl; CURL *curl;
curl_socket_t sock_fd;
char *orig_buf; char *orig_buf;
size_t buf_start; size_t buf_start;
size_t buf_off; size_t buf_off;
@@ -92,6 +93,7 @@ typedef struct BDRVCURLState {
static void curl_clean_state(CURLState *s); static void curl_clean_state(CURLState *s);
static void curl_multi_do(void *arg); static void curl_multi_do(void *arg);
static void curl_multi_read(void *arg);
#ifdef NEED_CURL_TIMER_CALLBACK #ifdef NEED_CURL_TIMER_CALLBACK
static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque) static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
@@ -113,16 +115,20 @@ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
void *s, void *sp) void *s, void *sp)
{ {
CURLState *state = NULL;
curl_easy_getinfo(curl, CURLINFO_PRIVATE, (char **)&state);
state->sock_fd = fd;
DPRINTF("CURL (AIO): Sock action %d on fd %d\n", action, fd); DPRINTF("CURL (AIO): Sock action %d on fd %d\n", action, fd);
switch (action) { switch (action) {
case CURL_POLL_IN: case CURL_POLL_IN:
qemu_aio_set_fd_handler(fd, curl_multi_do, NULL, s); qemu_aio_set_fd_handler(fd, curl_multi_read, NULL, state);
break; break;
case CURL_POLL_OUT: case CURL_POLL_OUT:
qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, s); qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, state);
break; break;
case CURL_POLL_INOUT: case CURL_POLL_INOUT:
qemu_aio_set_fd_handler(fd, curl_multi_do, curl_multi_do, s); qemu_aio_set_fd_handler(fd, curl_multi_read, curl_multi_do, state);
break; break;
case CURL_POLL_REMOVE: case CURL_POLL_REMOVE:
qemu_aio_set_fd_handler(fd, NULL, NULL, NULL); qemu_aio_set_fd_handler(fd, NULL, NULL, NULL);
@@ -155,7 +161,7 @@ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
DPRINTF("CURL: Just reading %zd bytes\n", realsize); DPRINTF("CURL: Just reading %zd bytes\n", realsize);
if (!s || !s->orig_buf) if (!s || !s->orig_buf)
goto read_end; return 0;
if (s->buf_off >= s->buf_len) { if (s->buf_off >= s->buf_len) {
/* buffer full, read nothing */ /* buffer full, read nothing */
@@ -180,7 +186,6 @@ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
} }
} }
read_end:
return realsize; return realsize;
} }
@@ -215,7 +220,8 @@ static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
} }
// Wait for unfinished chunks // Wait for unfinished chunks
if ((start >= state->buf_start) && if (state->in_use &&
(start >= state->buf_start) &&
(start <= buf_fend) && (start <= buf_fend) &&
(end >= state->buf_start) && (end >= state->buf_start) &&
(end <= buf_fend)) (end <= buf_fend))
@@ -237,68 +243,69 @@ static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
return FIND_RET_NONE; return FIND_RET_NONE;
} }
static void curl_multi_read(BDRVCURLState *s) static void curl_multi_check_completion(BDRVCURLState *s)
{ {
int msgs_in_queue; int msgs_in_queue;
/* Try to find done transfers, so we can free the easy /* Try to find done transfers, so we can free the easy
* handle again. */ * handle again. */
do { for (;;) {
CURLMsg *msg; CURLMsg *msg;
msg = curl_multi_info_read(s->multi, &msgs_in_queue); msg = curl_multi_info_read(s->multi, &msgs_in_queue);
/* Quit when there are no more completions */
if (!msg) if (!msg)
break; break;
if (msg->msg == CURLMSG_NONE)
break;
switch (msg->msg) { if (msg->msg == CURLMSG_DONE) {
case CURLMSG_DONE: CURLState *state = NULL;
{ curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE,
CURLState *state = NULL; (char **)&state);
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, (char**)&state);
/* ACBs for successful messages get completed in curl_read_cb */ /* ACBs for successful messages get completed in curl_read_cb */
if (msg->data.result != CURLE_OK) { if (msg->data.result != CURLE_OK) {
int i; int i;
for (i = 0; i < CURL_NUM_ACB; i++) { for (i = 0; i < CURL_NUM_ACB; i++) {
CURLAIOCB *acb = state->acb[i]; CURLAIOCB *acb = state->acb[i];
if (acb == NULL) { if (acb == NULL) {
continue; continue;
}
acb->common.cb(acb->common.opaque, -EIO);
qemu_aio_release(acb);
state->acb[i] = NULL;
} }
}
curl_clean_state(state); acb->common.cb(acb->common.opaque, -EIO);
break; qemu_aio_release(acb);
state->acb[i] = NULL;
}
} }
default:
msgs_in_queue = 0; curl_clean_state(state);
break; break;
} }
} while(msgs_in_queue); }
} }
static void curl_multi_do(void *arg) static void curl_multi_do(void *arg)
{ {
BDRVCURLState *s = (BDRVCURLState *)arg; CURLState *s = (CURLState *)arg;
int running; int running;
int r; int r;
if (!s->multi) { if (!s->s->multi) {
return; return;
} }
do { do {
r = curl_multi_socket_all(s->multi, &running); r = curl_multi_socket_action(s->s->multi, s->sock_fd, 0, &running);
} while(r == CURLM_CALL_MULTI_PERFORM); } while(r == CURLM_CALL_MULTI_PERFORM);
curl_multi_read(s); }
static void curl_multi_read(void *arg)
{
CURLState *s = (CURLState *)arg;
curl_multi_do(arg);
curl_multi_check_completion(s->s);
} }
static void curl_multi_timeout_do(void *arg) static void curl_multi_timeout_do(void *arg)
@@ -313,7 +320,7 @@ static void curl_multi_timeout_do(void *arg)
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running); curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
curl_multi_read(s); curl_multi_check_completion(s);
#else #else
abort(); abort();
#endif #endif
@@ -337,44 +344,42 @@ static CURLState *curl_init_state(BDRVCURLState *s)
break; break;
} }
if (!state) { if (!state) {
g_usleep(100); qemu_aio_wait();
curl_multi_do(s);
} }
} while(!state); } while(!state);
if (state->curl) if (!state->curl) {
goto has_curl; state->curl = curl_easy_init();
if (!state->curl) {
return NULL;
}
curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
(void *)curl_read_cb);
curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
state->curl = curl_easy_init(); /* Restrict supported protocols to avoid security issues in the more
if (!state->curl) * obscure protocols. For example, do not allow POP3/SMTP/IMAP see
return NULL; * CVE-2013-0249.
curl_easy_setopt(state->curl, CURLOPT_URL, s->url); *
curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5); * Restricting protocols is only supported from 7.19.4 upwards.
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb); */
curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
/* Restrict supported protocols to avoid security issues in the more
* obscure protocols. For example, do not allow POP3/SMTP/IMAP see
* CVE-2013-0249.
*
* Restricting protocols is only supported from 7.19.4 upwards.
*/
#if LIBCURL_VERSION_NUM >= 0x071304 #if LIBCURL_VERSION_NUM >= 0x071304
curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS); curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);
curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS); curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);
#endif #endif
#ifdef DEBUG_VERBOSE #ifdef DEBUG_VERBOSE
curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
#endif #endif
}
has_curl:
state->s = s; state->s = s;
@@ -531,19 +536,17 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
// initialize the multi interface! // initialize the multi interface!
s->multi = curl_multi_init(); s->multi = curl_multi_init();
curl_multi_setopt(s->multi, CURLMOPT_SOCKETDATA, s);
curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb); curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
#ifdef NEED_CURL_TIMER_CALLBACK #ifdef NEED_CURL_TIMER_CALLBACK
curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s); curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s);
curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb); curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb);
#endif #endif
curl_multi_do(s);
qemu_opts_del(opts); qemu_opts_del(opts);
return 0; return 0;
out: out:
fprintf(stderr, "CURL: Error opening file: %s\n", state->errmsg); error_setg(errp, "CURL: Error opening file: %s", state->errmsg);
curl_easy_cleanup(state->curl); curl_easy_cleanup(state->curl);
state->curl = NULL; state->curl = NULL;
out_noclean: out_noclean:
@@ -566,6 +569,7 @@ static const AIOCBInfo curl_aiocb_info = {
static void curl_readv_bh_cb(void *p) static void curl_readv_bh_cb(void *p)
{ {
CURLState *state; CURLState *state;
int running;
CURLAIOCB *acb = p; CURLAIOCB *acb = p;
BDRVCURLState *s = acb->common.bs->opaque; BDRVCURLState *s = acb->common.bs->opaque;
@@ -614,8 +618,9 @@ static void curl_readv_bh_cb(void *p)
curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range); curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);
curl_multi_add_handle(s->multi, state->curl); curl_multi_add_handle(s->multi, state->curl);
curl_multi_do(s);
/* Tell curl it needs to kick things off */
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
} }
static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs, static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,

View File

@@ -248,8 +248,8 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
offset += 8; offset += 8;
if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
error_report("sector count %" PRIu64 " for chunk %u is " error_report("sector count %" PRIu64 " for chunk %" PRIu32
"larger than max (%u)", " is larger than max (%u)",
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
@@ -269,8 +269,8 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
offset += 8; offset += 8;
if (s->lengths[i] > DMG_LENGTHS_MAX) { if (s->lengths[i] > DMG_LENGTHS_MAX) {
error_report("length %" PRIu64 " for chunk %u is larger " error_report("length %" PRIu64 " for chunk %" PRIu32
"than max (%u)", " is larger than max (%u)",
s->lengths[i], i, DMG_LENGTHS_MAX); s->lengths[i], i, DMG_LENGTHS_MAX);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;

View File

@@ -207,6 +207,11 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
"volume=%s image=%s transport=%s", gconf->server, "volume=%s image=%s transport=%s", gconf->server,
gconf->port, gconf->volname, gconf->image, gconf->port, gconf->volname, gconf->image,
gconf->transport); gconf->transport);
/* glfs_init sometimes doesn't set errno although docs suggest that */
if (errno == 0)
errno = EINVAL;
goto out; goto out;
} }
return glfs; return glfs;
@@ -482,7 +487,7 @@ static int qemu_gluster_create(const char *filename,
glfs = qemu_gluster_init(gconf, filename, errp); glfs = qemu_gluster_init(gconf, filename, errp);
if (!glfs) { if (!glfs) {
ret = -EINVAL; ret = -errno;
goto out; goto out;
} }

View File

@@ -2,7 +2,7 @@
* QEMU Block driver for iSCSI images * QEMU Block driver for iSCSI images
* *
* Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com> * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
* Copyright (c) 2012-2013 Peter Lieven <pl@kamp.de> * Copyright (c) 2012-2014 Peter Lieven <pl@kamp.de>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1095,16 +1095,15 @@ static struct scsi_task *iscsi_do_inquiry(struct iscsi_context *iscsi, int lun,
*inq = scsi_datain_unmarshall(task); *inq = scsi_datain_unmarshall(task);
if (*inq == NULL) { if (*inq == NULL) {
error_setg(errp, "iSCSI: failed to unmarshall inquiry datain blob"); error_setg(errp, "iSCSI: failed to unmarshall inquiry datain blob");
goto fail; goto fail_with_err;
} }
return task; return task;
fail: fail:
if (!error_is_set(errp)) { error_setg(errp, "iSCSI: Inquiry command failed : %s",
error_setg(errp, "iSCSI: Inquiry command failed : %s", iscsi_get_error(iscsi));
iscsi_get_error(iscsi)); fail_with_err:
}
if (task != NULL) { if (task != NULL) {
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
} }
@@ -1401,7 +1400,7 @@ static int iscsi_create(const char *filename, QEMUOptionParameter *options,
IscsiLun *iscsilun = NULL; IscsiLun *iscsilun = NULL;
QDict *bs_options; QDict *bs_options;
bs = bdrv_new(""); bs = bdrv_new("", &error_abort);
/* Read out options */ /* Read out options */
while (options && options->name) { while (options && options->name) {

View File

@@ -325,11 +325,11 @@ static void coroutine_fn mirror_run(void *opaque)
s->common.len = bdrv_getlength(bs); s->common.len = bdrv_getlength(bs);
if (s->common.len <= 0) { if (s->common.len <= 0) {
block_job_completed(&s->common, s->common.len); ret = s->common.len;
return; goto immediate_exit;
} }
length = (bdrv_getlength(bs) + s->granularity - 1) / s->granularity; length = DIV_ROUND_UP(s->common.len, s->granularity);
s->in_flight_bitmap = bitmap_new(length); s->in_flight_bitmap = bitmap_new(length);
/* If we have no backing file yet in the destination, we cannot let /* If we have no backing file yet in the destination, we cannot let
@@ -339,7 +339,10 @@ static void coroutine_fn mirror_run(void *opaque)
bdrv_get_backing_filename(s->target, backing_filename, bdrv_get_backing_filename(s->target, backing_filename,
sizeof(backing_filename)); sizeof(backing_filename));
if (backing_filename[0] && !s->target->backing_hd) { if (backing_filename[0] && !s->target->backing_hd) {
bdrv_get_info(s->target, &bdi); ret = bdrv_get_info(s->target, &bdi);
if (ret < 0) {
goto immediate_exit;
}
if (s->granularity < bdi.cluster_size) { if (s->granularity < bdi.cluster_size) {
s->buf_size = MAX(s->buf_size, bdi.cluster_size); s->buf_size = MAX(s->buf_size, bdi.cluster_size);
s->cow_bitmap = bitmap_new(length); s->cow_bitmap = bitmap_new(length);
@@ -605,7 +608,10 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
s->granularity = granularity; s->granularity = granularity;
s->buf_size = MAX(buf_size, granularity); s->buf_size = MAX(buf_size, granularity);
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity); s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, errp);
if (!s->dirty_bitmap) {
return;
}
bdrv_set_enable_write_cache(s->target, true); bdrv_set_enable_write_cache(s->target, true);
bdrv_set_on_error(s->target, on_target_error, on_target_error); bdrv_set_on_error(s->target, on_target_error, on_target_error);
bdrv_iostatus_enable(s->target); bdrv_iostatus_enable(s->target);
@@ -677,7 +683,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
mirror_start_job(bs, base, speed, 0, 0, mirror_start_job(bs, base, speed, 0, 0,
on_error, on_error, cb, opaque, &local_err, on_error, on_error, cb, opaque, &local_err,
&commit_active_job_driver, false, base); &commit_active_job_driver, false, base);
if (error_is_set(&local_err)) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
goto error_restore_flags; goto error_restore_flags;
} }

View File

@@ -175,7 +175,7 @@ static void nbd_parse_filename(const char *filename, QDict *options,
InetSocketAddress *addr = NULL; InetSocketAddress *addr = NULL;
addr = inet_parse(host_spec, errp); addr = inet_parse(host_spec, errp);
if (error_is_set(errp)) { if (!addr) {
goto out; goto out;
} }

View File

@@ -256,6 +256,10 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
error_setg(errp, "Invalid URL specified"); error_setg(errp, "Invalid URL specified");
goto fail; goto fail;
} }
if (!uri->server) {
error_setg(errp, "Invalid URL specified");
goto fail;
}
strp = strrchr(uri->path, '/'); strp = strrchr(uri->path, '/');
if (strp == NULL) { if (strp == NULL) {
error_setg(errp, "Invalid URL specified"); error_setg(errp, "Invalid URL specified");
@@ -343,7 +347,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err); qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
return -EINVAL; return -EINVAL;
} }

View File

@@ -532,12 +532,11 @@ static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
ImageInfoSpecific *info_spec) ImageInfoSpecific *info_spec)
{ {
Error *local_err = NULL;
QmpOutputVisitor *ov = qmp_output_visitor_new(); QmpOutputVisitor *ov = qmp_output_visitor_new();
QObject *obj, *data; QObject *obj, *data;
visit_type_ImageInfoSpecific(qmp_output_get_visitor(ov), &info_spec, NULL, visit_type_ImageInfoSpecific(qmp_output_get_visitor(ov), &info_spec, NULL,
&local_err); &error_abort);
obj = qmp_output_get_qobject(ov); obj = qmp_output_get_qobject(ov);
assert(qobject_type(obj) == QTYPE_QDICT); assert(qobject_type(obj) == QTYPE_QDICT);
data = qdict_get(qobject_to_qdict(obj), "data"); data = qdict_get(qobject_to_qdict(obj), "data");

View File

@@ -119,7 +119,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
} }
if (header.version != QCOW_VERSION) { if (header.version != QCOW_VERSION) {
char version[64]; char version[64];
snprintf(version, sizeof(version), "QCOW version %d", header.version); snprintf(version, sizeof(version), "QCOW version %" PRIu32,
header.version);
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bs->device_name, "qcow", version); bs->device_name, "qcow", version);
ret = -ENOTSUP; ret = -ENOTSUP;

View File

@@ -42,6 +42,13 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
if (min_size <= s->l1_size) if (min_size <= s->l1_size)
return 0; return 0;
/* Do a sanity check on min_size before trying to calculate new_l1_size
* (this prevents overflows during the while loop for the calculation of
* new_l1_size) */
if (min_size > INT_MAX / sizeof(uint64_t)) {
return -EFBIG;
}
if (exact_size) { if (exact_size) {
new_l1_size = min_size; new_l1_size = min_size;
} else { } else {
@@ -1360,9 +1367,9 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
for (i = 0; i < nb_clusters; i++) { for (i = 0; i < nb_clusters; i++) {
uint64_t old_offset; uint64_t old_l2_entry;
old_offset = be64_to_cpu(l2_table[l2_index + i]); old_l2_entry = be64_to_cpu(l2_table[l2_index + i]);
/* /*
* Make sure that a discarded area reads back as zeroes for v3 images * Make sure that a discarded area reads back as zeroes for v3 images
@@ -1373,12 +1380,22 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
* TODO We might want to use bdrv_get_block_status(bs) here, but we're * TODO We might want to use bdrv_get_block_status(bs) here, but we're
* holding s->lock, so that doesn't work today. * holding s->lock, so that doesn't work today.
*/ */
if (old_offset & QCOW_OFLAG_ZERO) { switch (qcow2_get_cluster_type(old_l2_entry)) {
continue; case QCOW2_CLUSTER_UNALLOCATED:
} if (!bs->backing_hd) {
continue;
}
break;
if ((old_offset & L2E_OFFSET_MASK) == 0 && !bs->backing_hd) { case QCOW2_CLUSTER_ZERO:
continue; continue;
case QCOW2_CLUSTER_NORMAL:
case QCOW2_CLUSTER_COMPRESSED:
break;
default:
abort();
} }
/* First remove L2 entries */ /* First remove L2 entries */
@@ -1390,7 +1407,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
} }
/* Then decrease the refcount */ /* Then decrease the refcount */
qcow2_free_any_clusters(bs, old_offset, 1, type); qcow2_free_any_clusters(bs, old_l2_entry, 1, type);
} }
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);

View File

@@ -653,6 +653,15 @@ retry:
goto retry; goto retry;
} }
} }
/* Make sure that all offsets in the "allocated" range are representable
* in an int64_t */
if (s->free_cluster_index > 0 &&
s->free_cluster_index - 1 > (INT64_MAX >> s->cluster_bits))
{
return -EFBIG;
}
#ifdef DEBUG_ALLOC2 #ifdef DEBUG_ALLOC2
fprintf(stderr, "alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n", fprintf(stderr, "alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n",
size, size,
@@ -1480,6 +1489,11 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
int ret; int ret;
size = bdrv_getlength(bs->file); size = bdrv_getlength(bs->file);
if (size < 0) {
res->check_errors++;
return size;
}
nb_clusters = size_to_clusters(s, size); nb_clusters = size_to_clusters(s, size);
if (nb_clusters > INT_MAX) { if (nb_clusters > INT_MAX) {
res->check_errors++; res->check_errors++;

View File

@@ -124,8 +124,9 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
case QCOW2_EXT_MAGIC_BACKING_FORMAT: case QCOW2_EXT_MAGIC_BACKING_FORMAT:
if (ext.len >= sizeof(bs->backing_format)) { if (ext.len >= sizeof(bs->backing_format)) {
error_setg(errp, "ERROR: ext_backing_format: len=%u too large" error_setg(errp, "ERROR: ext_backing_format: len=%" PRIu32
" (>=%zu)", ext.len, sizeof(bs->backing_format)); " too large (>=%zu)", ext.len,
sizeof(bs->backing_format));
return 2; return 2;
} }
ret = bdrv_pread(bs->file, offset, bs->backing_format, ext.len); ret = bdrv_pread(bs->file, offset, bs->backing_format, ext.len);
@@ -483,7 +484,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
goto fail; goto fail;
} }
if (header.version < 2 || header.version > 3) { if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version); report_unsupported(bs, errp, "QCOW version %" PRIu32, header.version);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} }
@@ -493,7 +494,8 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
/* Initialise cluster size */ /* Initialise cluster size */
if (header.cluster_bits < MIN_CLUSTER_BITS || if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) { header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits); error_setg(errp, "Unsupported cluster size: 2^%" PRIu32,
header.cluster_bits);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} }
@@ -591,7 +593,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
s->refcount_order = header.refcount_order; s->refcount_order = header.refcount_order;
if (header.crypt_method > QCOW_CRYPT_AES) { if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i", error_setg(errp, "Unsupported encryption method: %" PRIu32,
header.crypt_method); header.crypt_method);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;

View File

@@ -650,19 +650,21 @@ static int bdrv_qed_create(const char *filename, QEMUOptionParameter *options,
} }
if (!qed_is_cluster_size_valid(cluster_size)) { if (!qed_is_cluster_size_valid(cluster_size)) {
fprintf(stderr, "QED cluster size must be within range [%u, %u] and power of 2\n", error_setg(errp, "QED cluster size must be within range [%u, %u] "
QED_MIN_CLUSTER_SIZE, QED_MAX_CLUSTER_SIZE); "and power of 2",
QED_MIN_CLUSTER_SIZE, QED_MAX_CLUSTER_SIZE);
return -EINVAL; return -EINVAL;
} }
if (!qed_is_table_size_valid(table_size)) { if (!qed_is_table_size_valid(table_size)) {
fprintf(stderr, "QED table size must be within range [%u, %u] and power of 2\n", error_setg(errp, "QED table size must be within range [%u, %u] "
QED_MIN_TABLE_SIZE, QED_MAX_TABLE_SIZE); "and power of 2",
QED_MIN_TABLE_SIZE, QED_MAX_TABLE_SIZE);
return -EINVAL; return -EINVAL;
} }
if (!qed_is_image_size_valid(image_size, cluster_size, table_size)) { if (!qed_is_image_size_valid(image_size, cluster_size, table_size)) {
fprintf(stderr, "QED image size must be a non-zero multiple of " error_setg(errp, "QED image size must be a non-zero multiple of "
"cluster size and less than %" PRIu64 " bytes\n", "cluster size and less than %" PRIu64 " bytes",
qed_max_image_size(cluster_size, table_size)); qed_max_image_size(cluster_size, table_size));
return -EINVAL; return -EINVAL;
} }

View File

@@ -753,7 +753,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
opts = qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort); opts = qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err); qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
@@ -828,7 +828,7 @@ close_exit:
g_free(opened); g_free(opened);
exit: exit:
/* propagate error */ /* propagate error */
if (error_is_set(&local_err)) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
} }
QDECREF(list); QDECREF(list);

View File

@@ -146,6 +146,9 @@ typedef struct BDRVRawState {
bool has_discard:1; bool has_discard:1;
bool has_write_zeroes:1; bool has_write_zeroes:1;
bool discard_zeroes:1; bool discard_zeroes:1;
#ifdef CONFIG_FIEMAP
bool skip_fiemap;
#endif
} BDRVRawState; } BDRVRawState;
typedef struct BDRVRawReopenState { typedef struct BDRVRawReopenState {
@@ -366,7 +369,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
QemuOpts *opts; QemuOpts *opts;
Error *local_err = NULL; Error *local_err = NULL;
const char *filename; const char *filename = NULL;
int fd, ret; int fd, ret;
struct stat st; struct stat st;
@@ -446,6 +449,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
ret = 0; ret = 0;
fail: fail:
if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
unlink(filename);
}
qemu_opts_del(opts); qemu_opts_del(opts);
return ret; return ret;
} }
@@ -1269,6 +1275,83 @@ static int raw_create(const char *filename, QEMUOptionParameter *options,
return result; return result;
} }
static int64_t try_fiemap(BlockDriverState *bs, off_t start, off_t *data,
off_t *hole, int nb_sectors, int *pnum)
{
#ifdef CONFIG_FIEMAP
BDRVRawState *s = bs->opaque;
int64_t ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
struct {
struct fiemap fm;
struct fiemap_extent fe;
} f;
if (s->skip_fiemap) {
return -ENOTSUP;
}
f.fm.fm_start = start;
f.fm.fm_length = (int64_t)nb_sectors * BDRV_SECTOR_SIZE;
f.fm.fm_flags = 0;
f.fm.fm_extent_count = 1;
f.fm.fm_reserved = 0;
if (ioctl(s->fd, FS_IOC_FIEMAP, &f) == -1) {
s->skip_fiemap = true;
return -errno;
}
if (f.fm.fm_mapped_extents == 0) {
/* No extents found, data is beyond f.fm.fm_start + f.fm.fm_length.
* f.fm.fm_start + f.fm.fm_length must be clamped to the file size!
*/
off_t length = lseek(s->fd, 0, SEEK_END);
*hole = f.fm.fm_start;
*data = MIN(f.fm.fm_start + f.fm.fm_length, length);
} else {
*data = f.fe.fe_logical;
*hole = f.fe.fe_logical + f.fe.fe_length;
if (f.fe.fe_flags & FIEMAP_EXTENT_UNWRITTEN) {
ret |= BDRV_BLOCK_ZERO;
}
}
return ret;
#else
return -ENOTSUP;
#endif
}
static int64_t try_seek_hole(BlockDriverState *bs, off_t start, off_t *data,
off_t *hole, int *pnum)
{
#if defined SEEK_HOLE && defined SEEK_DATA
BDRVRawState *s = bs->opaque;
*hole = lseek(s->fd, start, SEEK_HOLE);
if (*hole == -1) {
/* -ENXIO indicates that sector_num was past the end of the file.
* There is a virtual hole there. */
assert(errno != -ENXIO);
return -errno;
}
if (*hole > start) {
*data = start;
} else {
/* On a hole. We need another syscall to find its end. */
*data = lseek(s->fd, start, SEEK_DATA);
if (*data == -1) {
*data = lseek(s->fd, 0, SEEK_END);
}
}
return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
#else
return -ENOTSUP;
#endif
}
/* /*
* Returns true iff the specified sector is present in the disk image. Drivers * Returns true iff the specified sector is present in the disk image. Drivers
* not implementing the functionality are assumed to not support backing files, * not implementing the functionality are assumed to not support backing files,
@@ -1285,10 +1368,10 @@ static int raw_create(const char *filename, QEMUOptionParameter *options,
* beyond the end of the disk image it will be clamped. * beyond the end of the disk image it will be clamped.
*/ */
static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
int64_t sector_num, int64_t sector_num,
int nb_sectors, int *pnum) int nb_sectors, int *pnum)
{ {
off_t start, data, hole; off_t start, data = 0, hole = 0;
int64_t ret; int64_t ret;
ret = fd_open(bs); ret = fd_open(bs);
@@ -1297,71 +1380,18 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
} }
start = sector_num * BDRV_SECTOR_SIZE; start = sector_num * BDRV_SECTOR_SIZE;
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
#ifdef CONFIG_FIEMAP ret = try_fiemap(bs, start, &data, &hole, nb_sectors, pnum);
if (ret < 0) {
BDRVRawState *s = bs->opaque; ret = try_seek_hole(bs, start, &data, &hole, pnum);
struct { if (ret < 0) {
struct fiemap fm; /* Assume everything is allocated. */
struct fiemap_extent fe; data = 0;
} f; hole = start + nb_sectors * BDRV_SECTOR_SIZE;
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
f.fm.fm_start = start;
f.fm.fm_length = (int64_t)nb_sectors * BDRV_SECTOR_SIZE;
f.fm.fm_flags = 0;
f.fm.fm_extent_count = 1;
f.fm.fm_reserved = 0;
if (ioctl(s->fd, FS_IOC_FIEMAP, &f) == -1) {
/* Assume everything is allocated. */
*pnum = nb_sectors;
return ret;
}
if (f.fm.fm_mapped_extents == 0) {
/* No extents found, data is beyond f.fm.fm_start + f.fm.fm_length.
* f.fm.fm_start + f.fm.fm_length must be clamped to the file size!
*/
off_t length = lseek(s->fd, 0, SEEK_END);
hole = f.fm.fm_start;
data = MIN(f.fm.fm_start + f.fm.fm_length, length);
} else {
data = f.fe.fe_logical;
hole = f.fe.fe_logical + f.fe.fe_length;
if (f.fe.fe_flags & FIEMAP_EXTENT_UNWRITTEN) {
ret |= BDRV_BLOCK_ZERO;
} }
} }
#elif defined SEEK_HOLE && defined SEEK_DATA
BDRVRawState *s = bs->opaque;
hole = lseek(s->fd, start, SEEK_HOLE);
if (hole == -1) {
/* -ENXIO indicates that sector_num was past the end of the file.
* There is a virtual hole there. */
assert(errno != -ENXIO);
/* Most likely EINVAL. Assume everything is allocated. */
*pnum = nb_sectors;
return ret;
}
if (hole > start) {
data = start;
} else {
/* On a hole. We need another syscall to find its end. */
data = lseek(s->fd, start, SEEK_DATA);
if (data == -1) {
data = lseek(s->fd, 0, SEEK_END);
}
}
#else
data = 0;
hole = start + nb_sectors * BDRV_SECTOR_SIZE;
#endif
if (data <= start) { if (data <= start) {
/* On a data extent, compute sectors to the end of the extent. */ /* On a data extent, compute sectors to the end of the extent. */
*pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE); *pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE);

View File

@@ -390,6 +390,9 @@ static void raw_close(BlockDriverState *bs)
{ {
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
CloseHandle(s->hfile); CloseHandle(s->hfile);
if (bs->open_flags & BDRV_O_TEMPORARY) {
unlink(bs->filename);
}
} }
static int raw_truncate(BlockDriverState *bs, int64_t offset) static int raw_truncate(BlockDriverState *bs, int64_t offset)

View File

@@ -1099,7 +1099,7 @@ static int find_vdi_name(BDRVSheepdogState *s, const char *filename,
} }
if (rsp->result != SD_RES_SUCCESS) { if (rsp->result != SD_RES_SUCCESS) {
error_report("cannot get vdi info, %s, %s %d %s", error_report("cannot get vdi info, %s, %s %" PRIu32 " %s",
sd_strerror(rsp->result), filename, snapid, tag); sd_strerror(rsp->result), filename, snapid, tag);
if (rsp->result == SD_RES_NO_VDI) { if (rsp->result == SD_RES_NO_VDI) {
ret = -ENOENT; ret = -ENOENT;
@@ -2316,8 +2316,8 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
sn_tab[found].vm_state_size = inode.vm_state_size; sn_tab[found].vm_state_size = inode.vm_state_size;
sn_tab[found].vm_clock_nsec = inode.vm_clock_nsec; sn_tab[found].vm_clock_nsec = inode.vm_clock_nsec;
snprintf(sn_tab[found].id_str, sizeof(sn_tab[found].id_str), "%u", snprintf(sn_tab[found].id_str, sizeof(sn_tab[found].id_str),
inode.snap_id); "%" PRIu32, inode.snap_id);
pstrcpy(sn_tab[found].name, pstrcpy(sn_tab[found].name,
MIN(sizeof(sn_tab[found].name), sizeof(inode.tag)), MIN(sizeof(sn_tab[found].name), sizeof(inode.tag)),
inode.tag); inode.tag);

View File

@@ -408,34 +408,35 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
} }
if (header.signature != VDI_SIGNATURE) { if (header.signature != VDI_SIGNATURE) {
error_setg(errp, "Image not in VDI format (bad signature %08x)", header.signature); error_setg(errp, "Image not in VDI format (bad signature %08" PRIx32
")", header.signature);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} else if (header.version != VDI_VERSION_1_1) { } else if (header.version != VDI_VERSION_1_1) {
error_setg(errp, "unsupported VDI image (version %u.%u)", error_setg(errp, "unsupported VDI image (version %" PRIu32 ".%" PRIu32
header.version >> 16, header.version & 0xffff); ")", header.version >> 16, header.version & 0xffff);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) { } else if (header.offset_bmap % SECTOR_SIZE != 0) {
/* We only support block maps which start on a sector boundary. */ /* We only support block maps which start on a sector boundary. */
error_setg(errp, "unsupported VDI image (unaligned block map offset " error_setg(errp, "unsupported VDI image (unaligned block map offset "
"0x%x)", header.offset_bmap); "0x%" PRIx32 ")", header.offset_bmap);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) { } else if (header.offset_data % SECTOR_SIZE != 0) {
/* We only support data blocks which start on a sector boundary. */ /* We only support data blocks which start on a sector boundary. */
error_setg(errp, "unsupported VDI image (unaligned data offset 0x%x)", error_setg(errp, "unsupported VDI image (unaligned data offset 0x%"
header.offset_data); PRIx32 ")", header.offset_data);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.sector_size != SECTOR_SIZE) { } else if (header.sector_size != SECTOR_SIZE) {
error_setg(errp, "unsupported VDI image (sector size %u is not %u)", error_setg(errp, "unsupported VDI image (sector size %" PRIu32
header.sector_size, SECTOR_SIZE); " is not %u)", header.sector_size, SECTOR_SIZE);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.block_size != DEFAULT_CLUSTER_SIZE) { } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
error_setg(errp, "unsupported VDI image (block size %u is not %u)", error_setg(errp, "unsupported VDI image (block size %" PRIu32
header.block_size, DEFAULT_CLUSTER_SIZE); " is not %u)", header.block_size, DEFAULT_CLUSTER_SIZE);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.disk_size > } else if (header.disk_size >
@@ -755,6 +756,7 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options,
vdi_header_to_le(&header); vdi_header_to_le(&header);
if (write(fd, &header, sizeof(header)) < 0) { if (write(fd, &header, sizeof(header)) < 0) {
result = -errno; result = -errno;
goto close_and_exit;
} }
if (bmap_size > 0) { if (bmap_size > 0) {
@@ -768,6 +770,8 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options,
} }
if (write(fd, bmap, bmap_size) < 0) { if (write(fd, bmap, bmap_size) < 0) {
result = -errno; result = -errno;
g_free(bmap);
goto close_and_exit;
} }
g_free(bmap); g_free(bmap);
} }
@@ -775,10 +779,12 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options,
if (image_type == VDI_TYPE_STATIC) { if (image_type == VDI_TYPE_STATIC) {
if (ftruncate(fd, sizeof(header) + bmap_size + blocks * block_size)) { if (ftruncate(fd, sizeof(header) + bmap_size + blocks * block_size)) {
result = -errno; result = -errno;
goto close_and_exit;
} }
} }
if (close(fd) < 0) { close_and_exit:
if ((close(fd) < 0) && !result) {
result = -errno; result = -errno;
} }

View File

@@ -262,7 +262,7 @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
p_name = strstr(desc, cid_str); p_name = strstr(desc, cid_str);
if (p_name != NULL) { if (p_name != NULL) {
p_name += cid_str_size; p_name += cid_str_size;
sscanf(p_name, "%x", &cid); sscanf(p_name, "%" SCNx32, &cid);
} }
return cid; return cid;
@@ -290,7 +290,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
p_name = strstr(desc, "CID"); p_name = strstr(desc, "CID");
if (p_name != NULL) { if (p_name != NULL) {
p_name += sizeof("CID"); p_name += sizeof("CID");
snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid); snprintf(p_name, sizeof(desc) - (p_name - desc), "%" PRIx32 "\n", cid);
pstrcat(desc, sizeof(desc), tmp_desc); pstrcat(desc, sizeof(desc), tmp_desc);
} }
@@ -640,7 +640,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
if (le32_to_cpu(header.version) > 3) { if (le32_to_cpu(header.version) > 3) {
char buf[64]; char buf[64];
snprintf(buf, sizeof(buf), "VMDK version %d", snprintf(buf, sizeof(buf), "VMDK version %" PRId32,
le32_to_cpu(header.version)); le32_to_cpu(header.version));
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bs->device_name, "vmdk", buf); bs->device_name, "vmdk", buf);
@@ -671,8 +671,9 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
} }
if (bdrv_getlength(file) < if (bdrv_getlength(file) <
le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) { le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) {
error_setg(errp, "File truncated, expecting at least %lld bytes", error_setg(errp, "File truncated, expecting at least %" PRId64 " bytes",
le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE); (int64_t)(le64_to_cpu(header.grain_offset)
* BDRV_SECTOR_SIZE));
return -EINVAL; return -EINVAL;
} }
@@ -1495,6 +1496,19 @@ static coroutine_fn int vmdk_co_write(BlockDriverState *bs, int64_t sector_num,
return ret; return ret;
} }
static int vmdk_write_compressed(BlockDriverState *bs,
int64_t sector_num,
const uint8_t *buf,
int nb_sectors)
{
BDRVVmdkState *s = bs->opaque;
if (s->num_extents == 1 && s->extents[0].compressed) {
return vmdk_write(bs, sector_num, buf, nb_sectors, false, false);
} else {
return -ENOTSUP;
}
}
static int coroutine_fn vmdk_co_write_zeroes(BlockDriverState *bs, static int coroutine_fn vmdk_co_write_zeroes(BlockDriverState *bs,
int64_t sector_num, int64_t sector_num,
int nb_sectors, int nb_sectors,
@@ -1707,8 +1721,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
const char desc_template[] = const char desc_template[] =
"# Disk DescriptorFile\n" "# Disk DescriptorFile\n"
"version=1\n" "version=1\n"
"CID=%x\n" "CID=%" PRIx32 "\n"
"parentCID=%x\n" "parentCID=%" PRIx32 "\n"
"createType=\"%s\"\n" "createType=\"%s\"\n"
"%s" "%s"
"\n" "\n"
@@ -1720,7 +1734,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
"\n" "\n"
"ddb.virtualHWVersion = \"%d\"\n" "ddb.virtualHWVersion = \"%d\"\n"
"ddb.geometry.cylinders = \"%" PRId64 "\"\n" "ddb.geometry.cylinders = \"%" PRId64 "\"\n"
"ddb.geometry.heads = \"%d\"\n" "ddb.geometry.heads = \"%" PRIu32 "\"\n"
"ddb.geometry.sectors = \"63\"\n" "ddb.geometry.sectors = \"63\"\n"
"ddb.adapterType = \"%s\"\n"; "ddb.adapterType = \"%s\"\n";
@@ -1780,9 +1794,9 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
strcmp(fmt, "twoGbMaxExtentFlat")); strcmp(fmt, "twoGbMaxExtentFlat"));
compress = !strcmp(fmt, "streamOptimized"); compress = !strcmp(fmt, "streamOptimized");
if (flat) { if (flat) {
desc_extent_line = "RW %lld FLAT \"%s\" 0\n"; desc_extent_line = "RW %" PRId64 " FLAT \"%s\" 0\n";
} else { } else {
desc_extent_line = "RW %lld SPARSE \"%s\"\n"; desc_extent_line = "RW %" PRId64 " SPARSE \"%s\"\n";
} }
if (flat && backing_file) { if (flat && backing_file) {
error_setg(errp, "Flat image can't have backing file"); error_setg(errp, "Flat image can't have backing file");
@@ -1850,7 +1864,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
} }
/* generate descriptor file */ /* generate descriptor file */
desc = g_strdup_printf(desc_template, desc = g_strdup_printf(desc_template,
(unsigned int)time(NULL), (uint32_t)time(NULL),
parent_cid, parent_cid,
fmt, fmt,
parent_desc_line, parent_desc_line,
@@ -2062,6 +2076,26 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
return spec_info; return spec_info;
} }
static int vmdk_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
int i;
BDRVVmdkState *s = bs->opaque;
assert(s->num_extents);
bdi->needs_compressed_writes = s->extents[0].compressed;
if (!s->extents[0].flat) {
bdi->cluster_size = s->extents[0].cluster_sectors << BDRV_SECTOR_BITS;
}
/* See if we have multiple extents but they have different cases */
for (i = 1; i < s->num_extents; i++) {
if (bdi->needs_compressed_writes != s->extents[i].compressed ||
(bdi->cluster_size && bdi->cluster_size !=
s->extents[i].cluster_sectors << BDRV_SECTOR_BITS)) {
return -ENOTSUP;
}
}
return 0;
}
static QEMUOptionParameter vmdk_create_options[] = { static QEMUOptionParameter vmdk_create_options[] = {
{ {
.name = BLOCK_OPT_SIZE, .name = BLOCK_OPT_SIZE,
@@ -2108,6 +2142,7 @@ static BlockDriver bdrv_vmdk = {
.bdrv_reopen_prepare = vmdk_reopen_prepare, .bdrv_reopen_prepare = vmdk_reopen_prepare,
.bdrv_read = vmdk_co_read, .bdrv_read = vmdk_co_read,
.bdrv_write = vmdk_co_write, .bdrv_write = vmdk_co_write,
.bdrv_write_compressed = vmdk_write_compressed,
.bdrv_co_write_zeroes = vmdk_co_write_zeroes, .bdrv_co_write_zeroes = vmdk_co_write_zeroes,
.bdrv_close = vmdk_close, .bdrv_close = vmdk_close,
.bdrv_create = vmdk_create, .bdrv_create = vmdk_create,
@@ -2117,6 +2152,7 @@ static BlockDriver bdrv_vmdk = {
.bdrv_has_zero_init = vmdk_has_zero_init, .bdrv_has_zero_init = vmdk_has_zero_init,
.bdrv_get_specific_info = vmdk_get_specific_info, .bdrv_get_specific_info = vmdk_get_specific_info,
.bdrv_refresh_limits = vmdk_refresh_limits, .bdrv_refresh_limits = vmdk_refresh_limits,
.bdrv_get_info = vmdk_get_info,
.create_options = vmdk_create_options, .create_options = vmdk_create_options,
}; };

View File

@@ -2947,7 +2947,7 @@ static int enable_write_target(BDRVVVFATState *s)
unlink(s->qcow_filename); unlink(s->qcow_filename);
#endif #endif
s->bs->backing_hd = bdrv_new(""); s->bs->backing_hd = bdrv_new("", &error_abort);
s->bs->backing_hd->drv = &vvfat_write_target; s->bs->backing_hd->drv = &vvfat_write_target;
s->bs->backing_hd->opaque = g_malloc(sizeof(void*)); s->bs->backing_hd->opaque = g_malloc(sizeof(void*));
*(void**)s->bs->backing_hd->opaque = s; *(void**)s->bs->backing_hd->opaque = s;

View File

@@ -452,16 +452,14 @@ static DriveInfo *blockdev_init(const char *file, QDict *bs_opts,
} }
} }
if (bdrv_find_node(qemu_opts_id(opts))) {
error_setg(errp, "device id=%s is conflicting with a node-name",
qemu_opts_id(opts));
goto early_err;
}
/* init */ /* init */
dinfo = g_malloc0(sizeof(*dinfo)); dinfo = g_malloc0(sizeof(*dinfo));
dinfo->id = g_strdup(qemu_opts_id(opts)); dinfo->id = g_strdup(qemu_opts_id(opts));
dinfo->bdrv = bdrv_new(dinfo->id); dinfo->bdrv = bdrv_new(dinfo->id, &error);
if (error) {
error_propagate(errp, error);
goto bdrv_new_err;
}
dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0; dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
dinfo->bdrv->read_only = ro; dinfo->bdrv->read_only = ro;
dinfo->refcount = 1; dinfo->refcount = 1;
@@ -523,8 +521,9 @@ static DriveInfo *blockdev_init(const char *file, QDict *bs_opts,
err: err:
bdrv_unref(dinfo->bdrv); bdrv_unref(dinfo->bdrv);
g_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next); QTAILQ_REMOVE(&drives, dinfo, next);
bdrv_new_err:
g_free(dinfo->id);
g_free(dinfo); g_free(dinfo);
early_err: early_err:
QDECREF(bs_opts); QDECREF(bs_opts);
@@ -1116,6 +1115,7 @@ typedef struct InternalSnapshotState {
static void internal_snapshot_prepare(BlkTransactionState *common, static void internal_snapshot_prepare(BlkTransactionState *common,
Error **errp) Error **errp)
{ {
Error *local_err = NULL;
const char *device; const char *device;
const char *name; const char *name;
BlockDriverState *bs; BlockDriverState *bs;
@@ -1164,8 +1164,10 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
} }
/* check whether a snapshot with name exist */ /* check whether a snapshot with name exist */
ret = bdrv_snapshot_find_by_id_and_name(bs, NULL, name, &old_sn, errp); ret = bdrv_snapshot_find_by_id_and_name(bs, NULL, name, &old_sn,
if (error_is_set(errp)) { &local_err);
if (local_err) {
error_propagate(errp, local_err);
return; return;
} else if (ret) { } else if (ret) {
error_setg(errp, error_setg(errp,
@@ -1521,14 +1523,16 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp)
return; return;
} }
if (!bdrv_dev_has_removable_media(bs)) { if (!bdrv_dev_has_removable_media(bs)) {
error_set(errp, QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs)); error_setg(errp, "Device '%s' is not removable",
bdrv_get_device_name(bs));
return; return;
} }
if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) { if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) {
bdrv_dev_eject_request(bs, force); bdrv_dev_eject_request(bs, force);
if (!force) { if (!force) {
error_set(errp, QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); error_setg(errp, "Device '%s' is locked",
bdrv_get_device_name(bs));
return; return;
} }
} }
@@ -2220,7 +2224,8 @@ void qmp_block_job_cancel(const char *device,
return; return;
} }
if (job->paused && !force) { if (job->paused && !force) {
error_set(errp, QERR_BLOCK_JOB_PAUSED, device); error_setg(errp, "The block job for device '%s' is currently paused",
device);
return; return;
} }

View File

@@ -88,7 +88,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
Error *local_err = NULL; Error *local_err = NULL;
if (!job->driver->set_speed) { if (!job->driver->set_speed) {
error_set(errp, QERR_NOT_SUPPORTED); error_set(errp, QERR_UNSUPPORTED);
return; return;
} }
job->driver->set_speed(job, speed, &local_err); job->driver->set_speed(job, speed, &local_err);

View File

@@ -43,7 +43,7 @@ unsigned long reserved_va;
#endif #endif
static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX; static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
const char *qemu_uname_release = CONFIG_UNAME_RELEASE; const char *qemu_uname_release;
extern char **environ; extern char **environ;
enum BSDType bsd_type; enum BSDType bsd_type;

62
configure vendored
View File

@@ -285,7 +285,6 @@ softmmu="yes"
linux_user="no" linux_user="no"
bsd_user="no" bsd_user="no"
guest_base="yes" guest_base="yes"
uname_release=""
aix="no" aix="no"
blobs="yes" blobs="yes"
pkgversion="" pkgversion=""
@@ -404,6 +403,14 @@ fi
# make source path absolute # make source path absolute
source_path=`cd "$source_path"; pwd` source_path=`cd "$source_path"; pwd`
# running configure in the source tree?
# we know that's the case if configure is there.
if test -f "./configure"; then
pwd_is_source_path="y"
else
pwd_is_source_path="n"
fi
check_define() { check_define() {
cat > $TMPC <<EOF cat > $TMPC <<EOF
#if !defined($1) #if !defined($1)
@@ -945,8 +952,6 @@ for opt do
;; ;;
--disable-pie) pie="no" --disable-pie) pie="no"
;; ;;
--enable-uname-release=*) uname_release="$optarg"
;;
--enable-werror) werror="yes" --enable-werror) werror="yes"
;; ;;
--disable-werror) werror="no" --disable-werror) werror="no"
@@ -1087,7 +1092,10 @@ for opt do
;; ;;
--enable-quorum) quorum="yes" --enable-quorum) quorum="yes"
;; ;;
*) echo "ERROR: unknown option $opt"; show_help="yes" *)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
exit 1
;; ;;
esac esac
done done
@@ -1217,8 +1225,8 @@ Advanced options (experts only):
--enable-modules enable modules support --enable-modules enable modules support
--enable-debug-tcg enable TCG debugging --enable-debug-tcg enable TCG debugging
--disable-debug-tcg disable TCG debugging (default) --disable-debug-tcg disable TCG debugging (default)
--enable-debug-info enable debugging information (default) --enable-debug-info enable debugging information (default)
--disable-debug-info disable debugging information --disable-debug-info disable debugging information
--enable-debug enable common debug build options --enable-debug enable common debug build options
--enable-sparse enable sparse checker --enable-sparse enable sparse checker
--disable-sparse disable sparse checker (default) --disable-sparse disable sparse checker (default)
@@ -1230,6 +1238,7 @@ Advanced options (experts only):
--with-sdlabi select preferred SDL ABI 1.2 or 2.0 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
--disable-gtk disable gtk UI --disable-gtk disable gtk UI
--enable-gtk enable gtk UI --enable-gtk enable gtk UI
--with-gtkabi select preferred GTK ABI 2.0 or 3.0
--disable-virtfs disable VirtFS --disable-virtfs disable VirtFS
--enable-virtfs enable VirtFS --enable-virtfs enable VirtFS
--disable-vnc disable VNC --disable-vnc disable VNC
@@ -1291,7 +1300,6 @@ Advanced options (experts only):
--fmod-lib path to FMOD library --fmod-lib path to FMOD library
--fmod-inc path to FMOD includes --fmod-inc path to FMOD includes
--oss-lib path to OSS library --oss-lib path to OSS library
--enable-uname-release=R Return R for uname -r in usermode emulation
--cpu=CPU Build for host CPU [$cpu] --cpu=CPU Build for host CPU [$cpu]
--disable-uuid disable uuid support --disable-uuid disable uuid support
--enable-uuid enable uuid support --enable-uuid enable uuid support
@@ -1353,7 +1361,7 @@ Advanced options (experts only):
NOTE: The object files are built at the place where configure is launched NOTE: The object files are built at the place where configure is launched
EOF EOF
exit 1 exit 0
fi fi
# Now we have handled --enable-tcg-interpreter and know we're not just # Now we have handled --enable-tcg-interpreter and know we're not just
@@ -2624,7 +2632,7 @@ done
if test "$modules" = yes; then if test "$modules" = yes; then
shacmd_probe="sha1sum sha1 shasum" shacmd_probe="sha1sum sha1 shasum"
for c in $shacmd_probe; do for c in $shacmd_probe; do
if which $c &>/dev/null; then if which $c >/dev/null 2>&1; then
shacmd="$c" shacmd="$c"
break break
fi fi
@@ -2940,7 +2948,7 @@ EOF
fdt=yes fdt=yes
dtc_internal="yes" dtc_internal="yes"
mkdir -p dtc mkdir -p dtc
if [ "$source_path" != `pwd` ] ; then if [ "$pwd_is_source_path" != "y" ] ; then
symlink "$source_path/dtc/Makefile" "dtc/Makefile" symlink "$source_path/dtc/Makefile" "dtc/Makefile"
symlink "$source_path/dtc/scripts" "dtc/scripts" symlink "$source_path/dtc/scripts" "dtc/scripts"
fi fi
@@ -3462,10 +3470,10 @@ if test "$smartcard_nss" != "no"; then
#include <pk11pub.h> #include <pk11pub.h>
int main(void) { PK11_FreeSlot(0); return 0; } int main(void) { PK11_FreeSlot(0); return 0; }
EOF EOF
smartcard_includes="-I\$(SRC_PATH)/libcacard" # FIXME: do not include $glib_* in here
libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs" nss_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags" nss_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
test_cflags="$libcacard_cflags" test_cflags="$nss_cflags"
# The header files in nss < 3.13.3 have a bug which causes them to # The header files in nss < 3.13.3 have a bug which causes them to
# emit a warning. If we're going to compile QEMU with -Werror, then # emit a warning. If we're going to compile QEMU with -Werror, then
# test that the headers don't have this bug. Otherwise we would pass # test that the headers don't have this bug. Otherwise we would pass
@@ -3475,11 +3483,8 @@ EOF
fi fi
if test -n "$libtool" && if test -n "$libtool" &&
$pkg_config --atleast-version=3.12.8 nss && \ $pkg_config --atleast-version=3.12.8 nss && \
compile_prog "$test_cflags" "$libcacard_libs"; then compile_prog "$test_cflags" "$nss_libs"; then
smartcard_nss="yes" smartcard_nss="yes"
QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
libs_softmmu="$libcacard_libs $libs_softmmu"
else else
if test "$smartcard_nss" = "yes"; then if test "$smartcard_nss" = "yes"; then
feature_not_found "nss" feature_not_found "nss"
@@ -4095,7 +4100,6 @@ echo "sparse enabled $sparse"
echo "strip binaries $strip_opt" echo "strip binaries $strip_opt"
echo "profiler $profiler" echo "profiler $profiler"
echo "static build $static" echo "static build $static"
echo "-Werror enabled $werror"
if test "$darwin" = "yes" ; then if test "$darwin" = "yes" ; then
echo "Cocoa support $cocoa" echo "Cocoa support $cocoa"
fi fi
@@ -4125,8 +4129,6 @@ echo "xen support $xen"
echo "brlapi support $brlapi" echo "brlapi support $brlapi"
echo "bluez support $bluez" echo "bluez support $bluez"
echo "Documentation $docs" echo "Documentation $docs"
[ ! -z "$uname_release" ] && \
echo "uname -r $uname_release"
echo "GUEST_BASE $guest_base" echo "GUEST_BASE $guest_base"
echo "PIE $pie" echo "PIE $pie"
echo "vde support $vde" echo "vde support $vde"
@@ -4148,7 +4150,9 @@ echo "libcap-ng support $cap_ng"
echo "vhost-net support $vhost_net" echo "vhost-net support $vhost_net"
echo "vhost-scsi support $vhost_scsi" echo "vhost-scsi support $vhost_scsi"
echo "Trace backend $trace_backend" echo "Trace backend $trace_backend"
if test "$trace_backend" = "simple"; then
echo "Trace output file $trace_file-<pid>" echo "Trace output file $trace_file-<pid>"
fi
if test "$spice" = "yes"; then if test "$spice" = "yes"; then
echo "spice support $spice ($spice_protocol_version/$spice_server_version)" echo "spice support $spice ($spice_protocol_version/$spice_server_version)"
else else
@@ -4347,6 +4351,7 @@ if test "$modules" = "yes"; then
fi fi
if test "$sdl" = "yes" ; then if test "$sdl" = "yes" ; then
echo "CONFIG_SDL=y" >> $config_host_mak echo "CONFIG_SDL=y" >> $config_host_mak
echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
fi fi
if test "$cocoa" = "yes" ; then if test "$cocoa" = "yes" ; then
@@ -4430,6 +4435,7 @@ fi
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
if test "$gtk" = "yes" ; then if test "$gtk" = "yes" ; then
echo "CONFIG_GTK=y" >> $config_host_mak echo "CONFIG_GTK=y" >> $config_host_mak
echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
fi fi
if test "$vte" = "yes" ; then if test "$vte" = "yes" ; then
@@ -4492,8 +4498,8 @@ fi
if test "$smartcard_nss" = "yes" ; then if test "$smartcard_nss" = "yes" ; then
echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
echo "libcacard_libs=$libcacard_libs" >> $config_host_mak echo "NSS_LIBS=$nss_libs" >> $config_host_mak
echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak echo "NSS_CFLAGS=$nss_cflags" >> $config_host_mak
fi fi
if test "$libusb" = "yes" ; then if test "$libusb" = "yes" ; then
@@ -4539,8 +4545,6 @@ if [ "$bsd" = "yes" ] ; then
echo "CONFIG_BSD=y" >> $config_host_mak echo "CONFIG_BSD=y" >> $config_host_mak
fi fi
echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
if test "$zero_malloc" = "yes" ; then if test "$zero_malloc" = "yes" ; then
echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
fi fi
@@ -4764,6 +4768,12 @@ if test "$gcov" = "yes" ; then
echo "GCOV=$gcov_tool" >> $config_host_mak echo "GCOV=$gcov_tool" >> $config_host_mak
fi fi
iotests_common_env="tests/qemu-iotests/common.env"
echo "# Automatically generated by configure - do not modify" > $iotests_common_env
echo >> $iotests_common_env
echo "PYTHON='$python'" >> $iotests_common_env
# use included Linux headers # use included Linux headers
if test "$linux" = "yes" ; then if test "$linux" = "yes" ; then
mkdir -p linux-headers mkdir -p linux-headers
@@ -5179,7 +5189,7 @@ do
done done
mkdir -p $DIRS mkdir -p $DIRS
for f in $FILES ; do for f in $FILES ; do
if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
symlink "$source_path/$f" "$f" symlink "$source_path/$f" "$f"
fi fi
done done

View File

@@ -115,14 +115,11 @@ static inline GThread *create_thread(GThreadFunc func, gpointer data)
static void __attribute__((constructor)) coroutine_init(void) static void __attribute__((constructor)) coroutine_init(void)
{ {
if (!g_thread_supported()) {
#if !GLIB_CHECK_VERSION(2, 31, 0) #if !GLIB_CHECK_VERSION(2, 31, 0)
if (!g_thread_supported()) {
g_thread_init(NULL); g_thread_init(NULL);
#else
fprintf(stderr, "glib threading failed to initialize.\n");
exit(1);
#endif
} }
#endif
init_coroutine_cond(); init_coroutine_cond();
} }

2
cpus.c
View File

@@ -1454,7 +1454,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename,
l = sizeof(buf); l = sizeof(buf);
if (l > size) if (l > size)
l = size; l = size;
cpu_physical_memory_rw(addr, buf, l, 0); cpu_physical_memory_read(addr, buf, l);
if (fwrite(buf, 1, l, f) != l) { if (fwrite(buf, 1, l, f) != l) {
error_set(errp, QERR_IO_ERROR); error_set(errp, QERR_IO_ERROR);
goto exit; goto exit;

View File

@@ -1,6 +1,7 @@
CONFIG_USB_TABLET_WACOM=y CONFIG_USB_TABLET_WACOM=y
CONFIG_USB_STORAGE_BOT=y CONFIG_USB_STORAGE_BOT=y
CONFIG_USB_STORAGE_UAS=y CONFIG_USB_STORAGE_UAS=y
CONFIG_USB_STORAGE_MTP=y
CONFIG_USB_SMARTCARD=y CONFIG_USB_SMARTCARD=y
CONFIG_USB_AUDIO=y CONFIG_USB_AUDIO=y
CONFIG_USB_SERIAL=y CONFIG_USB_SERIAL=y

View File

@@ -40,7 +40,7 @@ DriveInfo *add_init_drive(const char *optstr)
return NULL; return NULL;
mc = MACHINE_GET_CLASS(current_machine); mc = MACHINE_GET_CLASS(current_machine);
dinfo = drive_init(opts, mc->qemu_machine->block_default_type); dinfo = drive_init(opts, mc->block_default_type);
if (!dinfo) { if (!dinfo) {
qemu_opts_del(opts); qemu_opts_del(opts);
return NULL; return NULL;

View File

@@ -4,7 +4,7 @@ common-obj-$(CONFIG_ARM_DIS) += arm.o
common-obj-$(CONFIG_ARM_A64_DIS) += arm-a64.o common-obj-$(CONFIG_ARM_A64_DIS) += arm-a64.o
common-obj-$(CONFIG_ARM_A64_DIS) += libvixl/ common-obj-$(CONFIG_ARM_A64_DIS) += libvixl/
libvixldir = $(SRC_PATH)/disas/libvixl libvixldir = $(SRC_PATH)/disas/libvixl
$(obj)/arm-a64.o: QEMU_CFLAGS += -I$(libvixldir) arm-a64.o-cflags := -I$(libvixldir)
common-obj-$(CONFIG_CRIS_DIS) += cris.o common-obj-$(CONFIG_CRIS_DIS) += cris.o
common-obj-$(CONFIG_HPPA_DIS) += hppa.o common-obj-$(CONFIG_HPPA_DIS) += hppa.o
common-obj-$(CONFIG_I386_DIS) += i386.o common-obj-$(CONFIG_I386_DIS) += i386.o

View File

@@ -232,8 +232,8 @@ various constraints can be supplied to control how these callbacks are called:
(in bytes) supported by the *implementation*; other access sizes will be (in bytes) supported by the *implementation*; other access sizes will be
emulated using the ones available. For example a 4-byte write will be emulated using the ones available. For example a 4-byte write will be
emulated using four 1-byte writes, if .impl.max_access_size = 1. emulated using four 1-byte writes, if .impl.max_access_size = 1.
- .impl.valid specifies that the *implementation* only supports unaligned - .impl.unaligned specifies that the *implementation* supports unaligned
accesses; unaligned accesses will be emulated by two aligned accesses. accesses; if false, unaligned accesses will be emulated by two aligned
- .old_portio and .old_mmio can be used to ease porting from code using accesses.
cpu_register_io_memory() and register_ioport(). They should not be used - .old_mmio can be used to ease porting from code using
in new code. cpu_register_io_memory(). It should not be used in new code.

View File

@@ -139,7 +139,6 @@ static const VMStateDescription vmstate_kbd = {
.name = "pckbd", .name = "pckbd",
.version_id = 3, .version_id = 3,
.minimum_version_id = 3, .minimum_version_id = 3,
.minimum_version_id_old = 3,
.fields = (VMStateField []) { .fields = (VMStateField []) {
VMSTATE_UINT8(write_cmd, KBDState), VMSTATE_UINT8(write_cmd, KBDState),
VMSTATE_UINT8(status, KBDState), VMSTATE_UINT8(status, KBDState),
@@ -168,12 +167,13 @@ You can see that there are several version fields:
- minimum_version_id: the minimum version_id that VMState is able to understand - minimum_version_id: the minimum version_id that VMState is able to understand
for that device. for that device.
- minimum_version_id_old: For devices that were not able to port to vmstate, we can - minimum_version_id_old: For devices that were not able to port to vmstate, we can
assign a function that knows how to read this old state. assign a function that knows how to read this old state. This field is
ignored if there is no load_state_old handler.
So, VMState is able to read versions from minimum_version_id to So, VMState is able to read versions from minimum_version_id to
version_id. And the function load_state_old() is able to load state version_id. And the function load_state_old() (if present) is able to
from minimum_version_id_old to minimum_version_id. This function is load state from minimum_version_id_old to minimum_version_id. This
deprecated and will be removed when no more users are left. function is deprecated and will be removed when no more users are left.
=== Massaging functions === === Massaging functions ===
@@ -255,7 +255,6 @@ const VMStateDescription vmstate_ide_drive_pio_state = {
.name = "ide_drive/pio_state", .name = "ide_drive/pio_state",
.version_id = 1, .version_id = 1,
.minimum_version_id = 1, .minimum_version_id = 1,
.minimum_version_id_old = 1,
.pre_save = ide_drive_pio_pre_save, .pre_save = ide_drive_pio_pre_save,
.post_load = ide_drive_pio_post_load, .post_load = ide_drive_pio_post_load,
.fields = (VMStateField []) { .fields = (VMStateField []) {
@@ -275,7 +274,6 @@ const VMStateDescription vmstate_ide_drive = {
.name = "ide_drive", .name = "ide_drive",
.version_id = 3, .version_id = 3,
.minimum_version_id = 0, .minimum_version_id = 0,
.minimum_version_id_old = 0,
.post_load = ide_drive_post_load, .post_load = ide_drive_post_load,
.fields = (VMStateField []) { .fields = (VMStateField []) {
.... several fields .... .... several fields ....

View File

@@ -40,6 +40,17 @@ enumeration types and union types.
Generally speaking, types definitions should always use CamelCase for the type Generally speaking, types definitions should always use CamelCase for the type
names. Command names should be all lower case with words separated by a hyphen. names. Command names should be all lower case with words separated by a hyphen.
=== Includes ===
The QAPI schema definitions can be modularized using the 'include' directive:
{ 'include': 'path/to/file.json'}
The directive is evaluated recursively, and include paths are relative to the
file using the directive.
=== Complex types === === Complex types ===
A complex type is a dictionary containing a single key whose value is a A complex type is a dictionary containing a single key whose value is a
@@ -49,10 +60,34 @@ example of a complex type is:
{ 'type': 'MyType', { 'type': 'MyType',
'data': { 'member1': 'str', 'member2': 'int', '*member3': 'str' } } 'data': { 'member1': 'str', 'member2': 'int', '*member3': 'str' } }
The use of '*' as a prefix to the name means the member is optional. Optional The use of '*' as a prefix to the name means the member is optional.
members should always be added to the end of the dictionary to preserve
backwards compatibility.
The default initialization value of an optional argument should not be changed
between versions of QEMU unless the new default maintains backward
compatibility to the user-visible behavior of the old default.
With proper documentation, this policy still allows some flexibility; for
example, documenting that a default of 0 picks an optimal buffer size allows
one release to declare the optimal size at 512 while another release declares
the optimal size at 4096 - the user-visible behavior is not the bytes used by
the buffer, but the fact that the buffer was optimal size.
On input structures (only mentioned in the 'data' side of a command), changing
from mandatory to optional is safe (older clients will supply the option, and
newer clients can benefit from the default); changing from optional to
mandatory is backwards incompatible (older clients may be omitting the option,
and must continue to work).
On output structures (only mentioned in the 'returns' side of a command),
changing from mandatory to optional is in general unsafe (older clients may be
expecting the field, and could crash if it is missing), although it can be done
if the only way that the optional argument will be omitted is when it is
triggered by the presence of a new input flag to the command that older clients
don't know to send. Changing from optional to mandatory is safe.
A structure that is used in both input and output of various commands
must consider the backwards compatibility constraints of both directions
of use.
A complex type definition can specify another complex type as its base. A complex type definition can specify another complex type as its base.
In this case, the fields of the base type are included as top-level fields In this case, the fields of the base type are included as top-level fields
@@ -221,7 +256,7 @@ created code.
Example: Example:
mdroth@illuin:~/w/qemu2.git$ python scripts/qapi-types.py \ mdroth@illuin:~/w/qemu2.git$ python scripts/qapi-types.py \
--output-dir="qapi-generated" --prefix="example-" < example-schema.json --output-dir="qapi-generated" --prefix="example-" --input-file=example-schema.json
mdroth@illuin:~/w/qemu2.git$ cat qapi-generated/example-qapi-types.c mdroth@illuin:~/w/qemu2.git$ cat qapi-generated/example-qapi-types.c
/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
@@ -291,7 +326,7 @@ $(prefix)qapi-visit.h: declarations for previously mentioned visitor
Example: Example:
mdroth@illuin:~/w/qemu2.git$ python scripts/qapi-visit.py \ mdroth@illuin:~/w/qemu2.git$ python scripts/qapi-visit.py \
--output-dir="qapi-generated" --prefix="example-" < example-schema.json --output-dir="qapi-generated" --prefix="example-" --input-file=example-schema.json
mdroth@illuin:~/w/qemu2.git$ cat qapi-generated/example-qapi-visit.c mdroth@illuin:~/w/qemu2.git$ cat qapi-generated/example-qapi-visit.c
/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */

View File

@@ -5,9 +5,10 @@ QEMU Standard VGA
Exists in two variants, for isa and pci. Exists in two variants, for isa and pci.
command line switches: command line switches:
-vga std [ picks isa for -M isapc, otherwise pci ] -vga std [ picks isa for -M isapc, otherwise pci ]
-device VGA [ pci variant ] -device VGA [ pci variant ]
-device isa-vga [ isa variant ] -device isa-vga [ isa variant ]
-device secondary-vga [ legacy-free pci variant ]
PCI spec PCI spec
@@ -31,9 +32,15 @@ PCI ROM Region:
Holds the vgabios (qemu 0.14+). Holds the vgabios (qemu 0.14+).
The legacy-free variant has no ROM and has PCI_CLASS_DISPLAY_OTHER
instead of PCI_CLASS_DISPLAY_VGA.
IO ports used IO ports used
------------- -------------
Doesn't apply to the legacy-free pci variant, use the MMIO bar instead.
03c0 - 03df : standard vga ports 03c0 - 03df : standard vga ports
01ce : bochs vbe interface index port 01ce : bochs vbe interface index port
01cf : bochs vbe interface data port (x86 only) 01cf : bochs vbe interface data port (x86 only)

View File

@@ -308,12 +308,12 @@ Here's the implementation of the "hello-world" HMP command:
void hmp_hello_world(Monitor *mon, const QDict *qdict) void hmp_hello_world(Monitor *mon, const QDict *qdict)
{ {
const char *message = qdict_get_try_str(qdict, "message"); const char *message = qdict_get_try_str(qdict, "message");
Error *errp = NULL; Error *err = NULL;
qmp_hello_world(!!message, message, &errp); qmp_hello_world(!!message, message, &err);
if (error_is_set(&errp)) { if (err) {
monitor_printf(mon, "%s\n", error_get_pretty(errp)); monitor_printf(mon, "%s\n", error_get_pretty(err));
error_free(errp); error_free(err);
return; return;
} }
} }
@@ -328,7 +328,7 @@ There are three important points to be noticed:
2. hmp_hello_world() performs error checking. In this example we just print 2. hmp_hello_world() performs error checking. In this example we just print
the error description to the user, but we could do more, like taking the error description to the user, but we could do more, like taking
different actions depending on the error qmp_hello_world() returns different actions depending on the error qmp_hello_world() returns
3. The "errp" variable must be initialized to NULL before performing the 3. The "err" variable must be initialized to NULL before performing the
QMP call QMP call
There's one last step to actually make the command available to monitor users, There's one last step to actually make the command available to monitor users,
@@ -480,12 +480,12 @@ Here's the HMP counterpart of the query-alarm-clock command:
void hmp_info_alarm_clock(Monitor *mon) void hmp_info_alarm_clock(Monitor *mon)
{ {
QemuAlarmClock *clock; QemuAlarmClock *clock;
Error *errp = NULL; Error *err = NULL;
clock = qmp_query_alarm_clock(&errp); clock = qmp_query_alarm_clock(&err);
if (error_is_set(&errp)) { if (err) {
monitor_printf(mon, "Could not query alarm clock information\n"); monitor_printf(mon, "Could not query alarm clock information\n");
error_free(errp); error_free(err);
return; return;
} }
@@ -631,12 +631,12 @@ has to traverse the list, it's shown below for reference:
void hmp_info_alarm_methods(Monitor *mon) void hmp_info_alarm_methods(Monitor *mon)
{ {
TimerAlarmMethodList *method_list, *method; TimerAlarmMethodList *method_list, *method;
Error *errp = NULL; Error *err = NULL;
method_list = qmp_query_alarm_methods(&errp); method_list = qmp_query_alarm_methods(&err);
if (error_is_set(&errp)) { if (err) {
monitor_printf(mon, "Could not query alarm methods\n"); monitor_printf(mon, "Could not query alarm methods\n");
error_free(errp); error_free(err);
return; return;
} }

6
dump.c
View File

@@ -86,7 +86,6 @@ typedef struct DumpState {
bool has_filter; bool has_filter;
int64_t begin; int64_t begin;
int64_t length; int64_t length;
Error **errp;
uint8_t *note_buf; /* buffer for notes */ uint8_t *note_buf; /* buffer for notes */
size_t note_buf_offset; /* the writing place in note_buf */ size_t note_buf_offset; /* the writing place in note_buf */
@@ -1570,7 +1569,6 @@ static int dump_init(DumpState *s, int fd, bool has_format,
nr_cpus++; nr_cpus++;
} }
s->errp = errp;
s->fd = fd; s->fd = fd;
s->has_filter = has_filter; s->has_filter = has_filter;
s->begin = begin; s->begin = begin;
@@ -1780,11 +1778,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
} }
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) { if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
if (create_kdump_vmcore(s) < 0 && !error_is_set(s->errp)) { if (create_kdump_vmcore(s) < 0) {
error_set(errp, QERR_IO_ERROR); error_set(errp, QERR_IO_ERROR);
} }
} else { } else {
if (create_vmcore(s) < 0 && !error_is_set(s->errp)) { if (create_vmcore(s) < 0) {
error_set(errp, QERR_IO_ERROR); error_set(errp, QERR_IO_ERROR);
} }
} }

2
exec.c
View File

@@ -380,7 +380,7 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
as = iotlb.target_as; as = iotlb.target_as;
} }
if (memory_access_is_direct(mr, is_write)) { if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr; hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr;
len = MIN(page, len); len = MIN(page, len);
} }

View File

@@ -760,6 +760,7 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
return -1; return -1;
} }
size = sizeof(qemu);
client = accept(sock, (struct sockaddr *)&qemu, &size); client = accept(sock, (struct sockaddr *)&qemu, &size);
if (client < 0) { if (client < 0) {
do_perror("accept"); do_perror("accept");

View File

@@ -176,7 +176,7 @@ ETEXI
{ {
.name = "drive_del", .name = "drive_del",
.args_type = "id:s", .args_type = "id:B",
.params = "device", .params = "device",
.help = "remove host block device", .help = "remove host block device",
.user_print = monitor_user_noop, .user_print = monitor_user_noop,
@@ -658,6 +658,7 @@ ETEXI
.help = "add device, like -device on the command line", .help = "add device, like -device on the command line",
.user_print = monitor_user_noop, .user_print = monitor_user_noop,
.mhandler.cmd_new = do_device_add, .mhandler.cmd_new = do_device_add,
.command_completion = device_add_completion,
}, },
STEXI STEXI
@@ -673,6 +674,7 @@ ETEXI
.params = "device", .params = "device",
.help = "remove device", .help = "remove device",
.mhandler.cmd = hmp_device_del, .mhandler.cmd = hmp_device_del,
.command_completion = device_del_completion,
}, },
STEXI STEXI
@@ -998,26 +1000,34 @@ ETEXI
{ {
.name = "dump-guest-memory", .name = "dump-guest-memory",
.args_type = "paging:-p,filename:F,begin:i?,length:i?", .args_type = "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
.params = "[-p] filename [begin] [length]", .params = "[-p] [-z|-l|-s] filename [begin length]",
.help = "dump guest memory to file" .help = "dump guest memory into file 'filename'.\n\t\t\t"
"\n\t\t\t begin(optional): the starting physical address" "-p: do paging to get guest's memory mapping.\n\t\t\t"
"\n\t\t\t length(optional): the memory size, in bytes", "-z: dump in kdump-compressed format, with zlib compression.\n\t\t\t"
"-l: dump in kdump-compressed format, with lzo compression.\n\t\t\t"
"-s: dump in kdump-compressed format, with snappy compression.\n\t\t\t"
"begin: the starting physical address.\n\t\t\t"
"length: the memory size, in bytes.",
.mhandler.cmd = hmp_dump_guest_memory, .mhandler.cmd = hmp_dump_guest_memory,
}, },
STEXI STEXI
@item dump-guest-memory [-p] @var{protocol} @var{begin} @var{length} @item dump-guest-memory [-p] @var{filename} @var{begin} @var{length}
@item dump-guest-memory [-z|-l|-s] @var{filename}
@findex dump-guest-memory @findex dump-guest-memory
Dump guest memory to @var{protocol}. The file can be processed with crash or Dump guest memory to @var{protocol}. The file can be processed with crash or
gdb. gdb. Without -z|-l|-s, the dump format is ELF.
filename: dump file name -p: do paging to get guest's memory mapping.
paging: do paging to get guest's memory mapping -z: dump in kdump-compressed format, with zlib compression.
-l: dump in kdump-compressed format, with lzo compression.
-s: dump in kdump-compressed format, with snappy compression.
filename: dump file name.
begin: the starting physical address. It's optional, and should be begin: the starting physical address. It's optional, and should be
specified with length together. specified together with length.
length: the memory size, in bytes. It's optional, and should be specified length: the memory size, in bytes. It's optional, and should be specified
with begin together. together with begin.
ETEXI ETEXI
{ {
@@ -1254,6 +1264,7 @@ ETEXI
.params = "[qom-type=]type,id=str[,prop=value][,...]", .params = "[qom-type=]type,id=str[,prop=value][,...]",
.help = "create QOM object", .help = "create QOM object",
.mhandler.cmd = hmp_object_add, .mhandler.cmd = hmp_object_add,
.command_completion = object_add_completion,
}, },
STEXI STEXI
@@ -1268,6 +1279,7 @@ ETEXI
.params = "id", .params = "id",
.help = "destroy QOM object", .help = "destroy QOM object",
.mhandler.cmd = hmp_object_del, .mhandler.cmd = hmp_object_del,
.command_completion = object_del_completion,
}, },
STEXI STEXI

164
hmp.c
View File

@@ -28,7 +28,8 @@
static void hmp_handle_error(Monitor *mon, Error **errp) static void hmp_handle_error(Monitor *mon, Error **errp)
{ {
if (error_is_set(errp)) { assert(errp);
if (*errp) {
monitor_printf(mon, "%s\n", error_get_pretty(*errp)); monitor_printf(mon, "%s\n", error_get_pretty(*errp));
error_free(*errp); error_free(*errp);
} }
@@ -188,6 +189,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
info->ram->normal); info->ram->normal);
monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n", monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n",
info->ram->normal_bytes >> 10); info->ram->normal_bytes >> 10);
monitor_printf(mon, "dirty sync count: %" PRIu64 "\n",
info->ram->dirty_sync_count);
if (info->ram->dirty_pages_rate) { if (info->ram->dirty_pages_rate) {
monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n", monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n",
info->ram->dirty_pages_rate); info->ram->dirty_pages_rate);
@@ -212,6 +215,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
info->xbzrle_cache->pages); info->xbzrle_cache->pages);
monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n", monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n",
info->xbzrle_cache->cache_miss); info->xbzrle_cache->cache_miss);
monitor_printf(mon, "xbzrle cache miss rate: %0.2f\n",
info->xbzrle_cache->cache_miss_rate);
monitor_printf(mon, "xbzrle overflow : %" PRIu64 "\n", monitor_printf(mon, "xbzrle overflow : %" PRIu64 "\n",
info->xbzrle_cache->overflow); info->xbzrle_cache->overflow);
} }
@@ -750,10 +755,10 @@ void hmp_memsave(Monitor *mon, const QDict *qdict)
uint32_t size = qdict_get_int(qdict, "size"); uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename"); const char *filename = qdict_get_str(qdict, "filename");
uint64_t addr = qdict_get_int(qdict, "val"); uint64_t addr = qdict_get_int(qdict, "val");
Error *errp = NULL; Error *err = NULL;
qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &errp); qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_pmemsave(Monitor *mon, const QDict *qdict) void hmp_pmemsave(Monitor *mon, const QDict *qdict)
@@ -761,21 +766,21 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
uint32_t size = qdict_get_int(qdict, "size"); uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename"); const char *filename = qdict_get_str(qdict, "filename");
uint64_t addr = qdict_get_int(qdict, "val"); uint64_t addr = qdict_get_int(qdict, "val");
Error *errp = NULL; Error *err = NULL;
qmp_pmemsave(addr, size, filename, &errp); qmp_pmemsave(addr, size, filename, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_ringbuf_write(Monitor *mon, const QDict *qdict) void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
{ {
const char *chardev = qdict_get_str(qdict, "device"); const char *chardev = qdict_get_str(qdict, "device");
const char *data = qdict_get_str(qdict, "data"); const char *data = qdict_get_str(qdict, "data");
Error *errp = NULL; Error *err = NULL;
qmp_ringbuf_write(chardev, data, false, 0, &errp); qmp_ringbuf_write(chardev, data, false, 0, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
@@ -783,13 +788,13 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
uint32_t size = qdict_get_int(qdict, "size"); uint32_t size = qdict_get_int(qdict, "size");
const char *chardev = qdict_get_str(qdict, "device"); const char *chardev = qdict_get_str(qdict, "device");
char *data; char *data;
Error *errp = NULL; Error *err = NULL;
int i; int i;
data = qmp_ringbuf_read(chardev, size, false, 0, &errp); data = qmp_ringbuf_read(chardev, size, false, 0, &err);
if (errp) { if (err) {
monitor_printf(mon, "%s\n", error_get_pretty(errp)); monitor_printf(mon, "%s\n", error_get_pretty(err));
error_free(errp); error_free(err);
return; return;
} }
@@ -824,7 +829,7 @@ static bool key_is_missing(const BlockInfo *bdev)
void hmp_cont(Monitor *mon, const QDict *qdict) void hmp_cont(Monitor *mon, const QDict *qdict)
{ {
BlockInfoList *bdev_list, *bdev; BlockInfoList *bdev_list, *bdev;
Error *errp = NULL; Error *err = NULL;
bdev_list = qmp_query_block(NULL); bdev_list = qmp_query_block(NULL);
for (bdev = bdev_list; bdev; bdev = bdev->next) { for (bdev = bdev_list; bdev; bdev = bdev->next) {
@@ -835,8 +840,8 @@ void hmp_cont(Monitor *mon, const QDict *qdict)
} }
} }
qmp_cont(&errp); qmp_cont(&err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
out: out:
qapi_free_BlockInfoList(bdev_list); qapi_free_BlockInfoList(bdev_list);
@@ -849,41 +854,41 @@ void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
void hmp_inject_nmi(Monitor *mon, const QDict *qdict) void hmp_inject_nmi(Monitor *mon, const QDict *qdict)
{ {
Error *errp = NULL; Error *err = NULL;
qmp_inject_nmi(&errp); qmp_inject_nmi(&err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_set_link(Monitor *mon, const QDict *qdict) void hmp_set_link(Monitor *mon, const QDict *qdict)
{ {
const char *name = qdict_get_str(qdict, "name"); const char *name = qdict_get_str(qdict, "name");
int up = qdict_get_bool(qdict, "up"); int up = qdict_get_bool(qdict, "up");
Error *errp = NULL; Error *err = NULL;
qmp_set_link(name, up, &errp); qmp_set_link(name, up, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_block_passwd(Monitor *mon, const QDict *qdict) void hmp_block_passwd(Monitor *mon, const QDict *qdict)
{ {
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *password = qdict_get_str(qdict, "password"); const char *password = qdict_get_str(qdict, "password");
Error *errp = NULL; Error *err = NULL;
qmp_block_passwd(true, device, false, NULL, password, &errp); qmp_block_passwd(true, device, false, NULL, password, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_balloon(Monitor *mon, const QDict *qdict) void hmp_balloon(Monitor *mon, const QDict *qdict)
{ {
int64_t value = qdict_get_int(qdict, "value"); int64_t value = qdict_get_int(qdict, "value");
Error *errp = NULL; Error *err = NULL;
qmp_balloon(value, &errp); qmp_balloon(value, &err);
if (errp) { if (err) {
monitor_printf(mon, "balloon: %s\n", error_get_pretty(errp)); monitor_printf(mon, "balloon: %s\n", error_get_pretty(err));
error_free(errp); error_free(err);
} }
} }
@@ -891,10 +896,10 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
{ {
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
int64_t size = qdict_get_int(qdict, "size"); int64_t size = qdict_get_int(qdict, "size");
Error *errp = NULL; Error *err = NULL;
qmp_block_resize(true, device, false, NULL, size, &errp); qmp_block_resize(true, device, false, NULL, size, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_drive_mirror(Monitor *mon, const QDict *qdict) void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
@@ -905,11 +910,11 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
int reuse = qdict_get_try_bool(qdict, "reuse", 0); int reuse = qdict_get_try_bool(qdict, "reuse", 0);
int full = qdict_get_try_bool(qdict, "full", 0); int full = qdict_get_try_bool(qdict, "full", 0);
enum NewImageMode mode; enum NewImageMode mode;
Error *errp = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
error_set(&errp, QERR_MISSING_PARAMETER, "target"); error_set(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
return; return;
} }
@@ -922,8 +927,8 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
qmp_drive_mirror(device, filename, !!format, format, qmp_drive_mirror(device, filename, !!format, format,
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
true, mode, false, 0, false, 0, false, 0, true, mode, false, 0, false, 0, false, 0,
false, 0, false, 0, &errp); false, 0, false, 0, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_drive_backup(Monitor *mon, const QDict *qdict) void hmp_drive_backup(Monitor *mon, const QDict *qdict)
@@ -934,11 +939,11 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
int reuse = qdict_get_try_bool(qdict, "reuse", 0); int reuse = qdict_get_try_bool(qdict, "reuse", 0);
int full = qdict_get_try_bool(qdict, "full", 0); int full = qdict_get_try_bool(qdict, "full", 0);
enum NewImageMode mode; enum NewImageMode mode;
Error *errp = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
error_set(&errp, QERR_MISSING_PARAMETER, "target"); error_set(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
return; return;
} }
@@ -950,8 +955,8 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
qmp_drive_backup(device, filename, !!format, format, qmp_drive_backup(device, filename, !!format, format,
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
true, mode, false, 0, false, 0, false, 0, &errp); true, mode, false, 0, false, 0, false, 0, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
@@ -961,13 +966,13 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
const char *format = qdict_get_try_str(qdict, "format"); const char *format = qdict_get_try_str(qdict, "format");
int reuse = qdict_get_try_bool(qdict, "reuse", 0); int reuse = qdict_get_try_bool(qdict, "reuse", 0);
enum NewImageMode mode; enum NewImageMode mode;
Error *errp = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
/* In the future, if 'snapshot-file' is not specified, the snapshot /* In the future, if 'snapshot-file' is not specified, the snapshot
will be taken internally. Today it's actually required. */ will be taken internally. Today it's actually required. */
error_set(&errp, QERR_MISSING_PARAMETER, "snapshot-file"); error_set(&err, QERR_MISSING_PARAMETER, "snapshot-file");
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
return; return;
} }
@@ -975,18 +980,18 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
qmp_blockdev_snapshot_sync(true, device, false, NULL, qmp_blockdev_snapshot_sync(true, device, false, NULL,
filename, false, NULL, filename, false, NULL,
!!format, format, !!format, format,
true, mode, &errp); true, mode, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict) void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
{ {
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *name = qdict_get_str(qdict, "name"); const char *name = qdict_get_str(qdict, "name");
Error *errp = NULL; Error *err = NULL;
qmp_blockdev_snapshot_internal_sync(device, name, &errp); qmp_blockdev_snapshot_internal_sync(device, name, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict) void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
@@ -994,11 +999,11 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *name = qdict_get_str(qdict, "name"); const char *name = qdict_get_str(qdict, "name");
const char *id = qdict_get_try_str(qdict, "id"); const char *id = qdict_get_try_str(qdict, "id");
Error *errp = NULL; Error *err = NULL;
qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id, qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
true, name, &errp); true, name, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
@@ -1306,18 +1311,37 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{ {
Error *errp = NULL; Error *err = NULL;
int paging = qdict_get_try_bool(qdict, "paging", 0); int paging = qdict_get_try_bool(qdict, "paging", 0);
int zlib = qdict_get_try_bool(qdict, "zlib", 0);
int lzo = qdict_get_try_bool(qdict, "lzo", 0);
int snappy = qdict_get_try_bool(qdict, "snappy", 0);
const char *file = qdict_get_str(qdict, "filename"); const char *file = qdict_get_str(qdict, "filename");
bool has_begin = qdict_haskey(qdict, "begin"); bool has_begin = qdict_haskey(qdict, "begin");
bool has_length = qdict_haskey(qdict, "length"); bool has_length = qdict_haskey(qdict, "length");
/* kdump-compressed format is not supported for HMP */
bool has_format = false;
int64_t begin = 0; int64_t begin = 0;
int64_t length = 0; int64_t length = 0;
enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
char *prot; char *prot;
if (zlib + lzo + snappy > 1) {
error_setg(&err, "only one of '-z|-l|-s' can be set");
hmp_handle_error(mon, &err);
return;
}
if (zlib) {
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
}
if (lzo) {
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
}
if (snappy) {
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
}
if (has_begin) { if (has_begin) {
begin = qdict_get_int(qdict, "begin"); begin = qdict_get_int(qdict, "begin");
} }
@@ -1328,8 +1352,8 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
prot = g_strconcat("file:", file, NULL); prot = g_strconcat("file:", file, NULL);
qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length, qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
has_format, dump_format, &errp); true, dump_format, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
g_free(prot); g_free(prot);
} }
@@ -1421,19 +1445,19 @@ out:
void hmp_getfd(Monitor *mon, const QDict *qdict) void hmp_getfd(Monitor *mon, const QDict *qdict)
{ {
const char *fdname = qdict_get_str(qdict, "fdname"); const char *fdname = qdict_get_str(qdict, "fdname");
Error *errp = NULL; Error *err = NULL;
qmp_getfd(fdname, &errp); qmp_getfd(fdname, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_closefd(Monitor *mon, const QDict *qdict) void hmp_closefd(Monitor *mon, const QDict *qdict)
{ {
const char *fdname = qdict_get_str(qdict, "fdname"); const char *fdname = qdict_get_str(qdict, "fdname");
Error *errp = NULL; Error *err = NULL;
qmp_closefd(fdname, &errp); qmp_closefd(fdname, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_send_key(Monitor *mon, const QDict *qdict) void hmp_send_key(Monitor *mon, const QDict *qdict)
@@ -1583,10 +1607,10 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict) void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
{ {
Error *errp = NULL; Error *err = NULL;
qmp_nbd_server_stop(&errp); qmp_nbd_server_stop(&err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_cpu_add(Monitor *mon, const QDict *qdict) void hmp_cpu_add(Monitor *mon, const QDict *qdict)

5
hmp.h
View File

@@ -15,6 +15,7 @@
#define HMP_H #define HMP_H
#include "qemu-common.h" #include "qemu-common.h"
#include "qemu/readline.h"
#include "qapi-types.h" #include "qapi-types.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
@@ -92,5 +93,9 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_cpu_add(Monitor *mon, const QDict *qdict);
void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict);
void hmp_object_del(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict);
void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
void device_del_completion(ReadLineState *rs, int nb_args, const char *str);
#endif #endif

View File

@@ -14,6 +14,7 @@
#include "hw/virtio/virtio.h" #include "hw/virtio/virtio.h"
#include "virtio-9p.h" #include "virtio-9p.h"
#include "virtio-9p-xattr.h" #include "virtio-9p-xattr.h"
#include "fsdev/qemu-fsdev.h" /* local_ops */
#include <arpa/inet.h> #include <arpa/inet.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>

View File

@@ -21,7 +21,7 @@
#include <sys/stat.h> #include <sys/stat.h>
/* Root node for synth file system */ /* Root node for synth file system */
V9fsSynthNode v9fs_synth_root = { static V9fsSynthNode v9fs_synth_root = {
.name = "/", .name = "/",
.actual_attr = { .actual_attr = {
.mode = 0555 | S_IFDIR, .mode = 0555 | S_IFDIR,

View File

@@ -987,8 +987,9 @@ static void v9fs_attach(void *opaque)
*/ */
if (!s->migration_blocker) { if (!s->migration_blocker) {
s->root_fid = fid; s->root_fid = fid;
error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION, error_setg(&s->migration_blocker,
s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag); "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'",
s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag);
migrate_add_blocker(s->migration_blocker); migrate_add_blocker(s->migration_blocker);
} }
out: out:

View File

@@ -63,16 +63,18 @@ typedef struct AcpiPciHpFind {
static int acpi_pcihp_get_bsel(PCIBus *bus) static int acpi_pcihp_get_bsel(PCIBus *bus)
{ {
QObject *o = object_property_get_qobject(OBJECT(bus), Error *local_err = NULL;
ACPI_PCIHP_PROP_BSEL, NULL); int64_t bsel = object_property_get_int(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
int64_t bsel = -1; &local_err);
if (o) {
bsel = qint_get_int(qobject_to_qint(o)); if (local_err || bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
} if (local_err) {
if (bsel < 0) { error_free(local_err);
}
return -1; return -1;
} else {
return bsel;
} }
return bsel;
} }
static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque)

View File

@@ -43,6 +43,19 @@ static void cubieboard_init(QEMUMachineInitArgs *args)
exit(1); exit(1);
} }
object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err);
if (err != NULL) {
error_report("Couldn't set clk0 frequency: %s", error_get_pretty(err));
exit(1);
}
object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq",
&err);
if (err != NULL) {
error_report("Couldn't set clk1 frequency: %s", error_get_pretty(err));
exit(1);
}
object_property_set_bool(OBJECT(s->a10), true, "realized", &err); object_property_set_bool(OBJECT(s->a10), true, "realized", &err);
if (err != NULL) { if (err != NULL) {
error_report("Couldn't realize Allwinner A10: %s", error_report("Couldn't realize Allwinner A10: %s",

View File

@@ -732,7 +732,7 @@ static void pxa2xx_ssp_save(QEMUFile *f, void *opaque)
static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id) static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id)
{ {
PXA2xxSSPState *s = (PXA2xxSSPState *) opaque; PXA2xxSSPState *s = (PXA2xxSSPState *) opaque;
int i; int i, v;
s->enable = qemu_get_be32(f); s->enable = qemu_get_be32(f);
@@ -746,7 +746,11 @@ static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_8s(f, &s->ssrsa); qemu_get_8s(f, &s->ssrsa);
qemu_get_8s(f, &s->ssacd); qemu_get_8s(f, &s->ssacd);
s->rx_level = qemu_get_byte(f); v = qemu_get_byte(f);
if (v < 0 || v > ARRAY_SIZE(s->rx_fifo)) {
return -EINVAL;
}
s->rx_level = v;
s->rx_start = 0; s->rx_start = 0;
for (i = 0; i < s->rx_level; i ++) for (i = 0; i < s->rx_level; i ++)
s->rx_fifo[i] = qemu_get_byte(f); s->rx_fifo[i] = qemu_get_byte(f);

View File

@@ -75,8 +75,6 @@ typedef struct MemMapEntry {
typedef struct VirtBoardInfo { typedef struct VirtBoardInfo {
struct arm_boot_info bootinfo; struct arm_boot_info bootinfo;
const char *cpu_model; const char *cpu_model;
const char *qdevname;
const char *gic_compatible;
const MemMapEntry *memmap; const MemMapEntry *memmap;
const int *irqmap; const int *irqmap;
int smp_cpus; int smp_cpus;
@@ -98,10 +96,10 @@ typedef struct VirtBoardInfo {
static const MemMapEntry a15memmap[] = { static const MemMapEntry a15memmap[] = {
/* Space up to 0x8000000 is reserved for a boot ROM */ /* Space up to 0x8000000 is reserved for a boot ROM */
[VIRT_FLASH] = { 0, 0x8000000 }, [VIRT_FLASH] = { 0, 0x8000000 },
[VIRT_CPUPERIPHS] = { 0x8000000, 0x8000 }, [VIRT_CPUPERIPHS] = { 0x8000000, 0x20000 },
/* GIC distributor and CPU interfaces sit inside the CPU peripheral space */ /* GIC distributor and CPU interfaces sit inside the CPU peripheral space */
[VIRT_GIC_DIST] = { 0x8001000, 0x1000 }, [VIRT_GIC_DIST] = { 0x8000000, 0x10000 },
[VIRT_GIC_CPU] = { 0x8002000, 0x1000 }, [VIRT_GIC_CPU] = { 0x8010000, 0x10000 },
[VIRT_UART] = { 0x9000000, 0x1000 }, [VIRT_UART] = { 0x9000000, 0x1000 },
[VIRT_MMIO] = { 0xa000000, 0x200 }, [VIRT_MMIO] = { 0xa000000, 0x200 },
/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
@@ -117,16 +115,16 @@ static const int a15irqmap[] = {
static VirtBoardInfo machines[] = { static VirtBoardInfo machines[] = {
{ {
.cpu_model = "cortex-a15", .cpu_model = "cortex-a15",
.qdevname = "a15mpcore_priv", .memmap = a15memmap,
.gic_compatible = "arm,cortex-a15-gic", .irqmap = a15irqmap,
},
{
.cpu_model = "cortex-a57",
.memmap = a15memmap, .memmap = a15memmap,
.irqmap = a15irqmap, .irqmap = a15irqmap,
}, },
{ {
.cpu_model = "host", .cpu_model = "host",
/* We use the A15 private peripheral model to get a V2 GIC */
.qdevname = "a15mpcore_priv",
.gic_compatible = "arm,cortex-a15-gic",
.memmap = a15memmap, .memmap = a15memmap,
.irqmap = a15irqmap, .irqmap = a15irqmap,
}, },
@@ -251,8 +249,9 @@ static void fdt_add_gic_node(const VirtBoardInfo *vbi)
qemu_fdt_setprop_cell(vbi->fdt, "/", "interrupt-parent", gic_phandle); qemu_fdt_setprop_cell(vbi->fdt, "/", "interrupt-parent", gic_phandle);
qemu_fdt_add_subnode(vbi->fdt, "/intc"); qemu_fdt_add_subnode(vbi->fdt, "/intc");
/* 'cortex-a15-gic' means 'GIC v2' */
qemu_fdt_setprop_string(vbi->fdt, "/intc", "compatible", qemu_fdt_setprop_string(vbi->fdt, "/intc", "compatible",
vbi->gic_compatible); "arm,cortex-a15-gic");
qemu_fdt_setprop_cell(vbi->fdt, "/intc", "#interrupt-cells", 3); qemu_fdt_setprop_cell(vbi->fdt, "/intc", "#interrupt-cells", 3);
qemu_fdt_setprop(vbi->fdt, "/intc", "interrupt-controller", NULL, 0); qemu_fdt_setprop(vbi->fdt, "/intc", "interrupt-controller", NULL, 0);
qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc", "reg", qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc", "reg",
@@ -263,6 +262,56 @@ static void fdt_add_gic_node(const VirtBoardInfo *vbi)
qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", gic_phandle); qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", gic_phandle);
} }
static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
{
/* We create a standalone GIC v2 */
DeviceState *gicdev;
SysBusDevice *gicbusdev;
const char *gictype = "arm_gic";
int i;
if (kvm_irqchip_in_kernel()) {
gictype = "kvm-arm-gic";
}
gicdev = qdev_create(NULL, gictype);
qdev_prop_set_uint32(gicdev, "revision", 2);
qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
/* Note that the num-irq property counts both internal and external
* interrupts; there are always 32 of the former (mandated by GIC spec).
*/
qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32);
qdev_init_nofail(gicdev);
gicbusdev = SYS_BUS_DEVICE(gicdev);
sysbus_mmio_map(gicbusdev, 0, vbi->memmap[VIRT_GIC_DIST].base);
sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_CPU].base);
/* Wire the outputs from each CPU's generic timer to the
* appropriate GIC PPI inputs, and the GIC's IRQ output to
* the CPU's IRQ input.
*/
for (i = 0; i < smp_cpus; i++) {
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
int ppibase = NUM_IRQS + i * 32;
/* physical timer; we wire it up to the non-secure timer's ID,
* since a real A15 always has TrustZone but QEMU doesn't.
*/
qdev_connect_gpio_out(cpudev, 0,
qdev_get_gpio_in(gicdev, ppibase + 30));
/* virtual timer */
qdev_connect_gpio_out(cpudev, 1,
qdev_get_gpio_in(gicdev, ppibase + 27));
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
}
for (i = 0; i < NUM_IRQS; i++) {
pic[i] = qdev_get_gpio_in(gicdev, i);
}
fdt_add_gic_node(vbi);
}
static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
{ {
char *nodename; char *nodename;
@@ -340,8 +389,6 @@ static void machvirt_init(QEMUMachineInitArgs *args)
MemoryRegion *sysmem = get_system_memory(); MemoryRegion *sysmem = get_system_memory();
int n; int n;
MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *ram = g_new(MemoryRegion, 1);
DeviceState *dev;
SysBusDevice *busdev;
const char *cpu_model = args->cpu_model; const char *cpu_model = args->cpu_model;
VirtBoardInfo *vbi; VirtBoardInfo *vbi;
@@ -404,25 +451,7 @@ static void machvirt_init(QEMUMachineInitArgs *args)
vmstate_register_ram_global(ram); vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, vbi->memmap[VIRT_MEM].base, ram); memory_region_add_subregion(sysmem, vbi->memmap[VIRT_MEM].base, ram);
dev = qdev_create(NULL, vbi->qdevname); create_gic(vbi, pic);
qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
/* Note that the num-irq property counts both internal and external
* interrupts; there are always 32 of the former (mandated by GIC spec).
*/
qdev_prop_set_uint32(dev, "num-irq", NUM_IRQS + 32);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, vbi->memmap[VIRT_CPUPERIPHS].base);
fdt_add_gic_node(vbi);
for (n = 0; n < smp_cpus; n++) {
DeviceState *cpudev = DEVICE(qemu_get_cpu(n));
sysbus_connect_irq(busdev, n, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
}
for (n = 0; n < NUM_IRQS; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
create_uart(vbi, pic); create_uart(vbi, pic);

View File

@@ -86,6 +86,7 @@ typedef struct {
#ifndef HAS_YMF262 #ifndef HAS_YMF262
FM_OPL *opl; FM_OPL *opl;
#endif #endif
PortioList port_list;
} AdlibState; } AdlibState;
static AdlibState *glob_adlib; static AdlibState *glob_adlib;
@@ -293,7 +294,6 @@ static MemoryRegionPortio adlib_portio_list[] = {
static void adlib_realizefn (DeviceState *dev, Error **errp) static void adlib_realizefn (DeviceState *dev, Error **errp)
{ {
AdlibState *s = ADLIB(dev); AdlibState *s = ADLIB(dev);
PortioList *port_list = g_new(PortioList, 1);
struct audsettings as; struct audsettings as;
if (glob_adlib) { if (glob_adlib) {
@@ -349,8 +349,8 @@ static void adlib_realizefn (DeviceState *dev, Error **errp)
adlib_portio_list[0].offset = s->port; adlib_portio_list[0].offset = s->port;
adlib_portio_list[1].offset = s->port + 8; adlib_portio_list[1].offset = s->port + 8;
portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, "adlib"); portio_list_init (&s->port_list, OBJECT(s), adlib_portio_list, s, "adlib");
portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0); portio_list_add (&s->port_list, isa_address_space_io(&s->parent_obj), 0);
} }
static Property adlib_properties[] = { static Property adlib_properties[] = {

View File

@@ -261,6 +261,9 @@ static void hda_audio_set_amp(HDAAudioStream *st)
left = left * 255 / QEMU_HDA_AMP_STEPS; left = left * 255 / QEMU_HDA_AMP_STEPS;
right = right * 255 / QEMU_HDA_AMP_STEPS; right = right * 255 / QEMU_HDA_AMP_STEPS;
if (!st->state->mixer) {
return;
}
if (st->output) { if (st->output) {
AUD_set_volume_out(st->voice.out, muted, left, right); AUD_set_volume_out(st->voice.out, muted, left, right);
} else { } else {

View File

@@ -79,6 +79,12 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque
dst->handle = src->handle; dst->handle = src->handle;
dst->id = src->id; dst->id = src->id;
dst->sector_number = src->sector_number; dst->sector_number = src->sector_number;
if (src->operation == BLKIF_OP_DISCARD) {
struct blkif_request_discard *s = (void *)src;
struct blkif_request_discard *d = (void *)dst;
d->nr_sectors = s->nr_sectors;
return;
}
if (n > src->nr_segments) if (n > src->nr_segments)
n = src->nr_segments; n = src->nr_segments;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
@@ -94,6 +100,12 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque
dst->handle = src->handle; dst->handle = src->handle;
dst->id = src->id; dst->id = src->id;
dst->sector_number = src->sector_number; dst->sector_number = src->sector_number;
if (src->operation == BLKIF_OP_DISCARD) {
struct blkif_request_discard *s = (void *)src;
struct blkif_request_discard *d = (void *)dst;
d->nr_sectors = s->nr_sectors;
return;
}
if (n > src->nr_segments) if (n > src->nr_segments)
n = src->nr_segments; n = src->nr_segments;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)

View File

@@ -114,6 +114,7 @@ struct XenBlkDev {
int requests_finished; int requests_finished;
/* Persistent grants extension */ /* Persistent grants extension */
gboolean feature_discard;
gboolean feature_persistent; gboolean feature_persistent;
GTree *persistent_gnts; GTree *persistent_gnts;
unsigned int persistent_gnt_count; unsigned int persistent_gnt_count;
@@ -253,6 +254,8 @@ static int ioreq_parse(struct ioreq *ioreq)
case BLKIF_OP_WRITE: case BLKIF_OP_WRITE:
ioreq->prot = PROT_READ; /* from memory */ ioreq->prot = PROT_READ; /* from memory */
break; break;
case BLKIF_OP_DISCARD:
return 0;
default: default:
xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n", xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
ioreq->req.operation); ioreq->req.operation);
@@ -492,6 +495,7 @@ static void qemu_aio_complete(void *opaque, int ret)
case BLKIF_OP_READ: case BLKIF_OP_READ:
bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct); bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
break; break;
case BLKIF_OP_DISCARD:
default: default:
break; break;
} }
@@ -532,6 +536,15 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
&ioreq->v, ioreq->v.size / BLOCK_SIZE, &ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq); qemu_aio_complete, ioreq);
break; break;
case BLKIF_OP_DISCARD:
{
struct blkif_request_discard *discard_req = (void *)&ioreq->req;
ioreq->aio_inflight++;
bdrv_aio_discard(blkdev->bs,
discard_req->sector_number, discard_req->nr_sectors,
qemu_aio_complete, ioreq);
break;
}
default: default:
/* unknown operation (shouldn't happen -- parse catches this) */ /* unknown operation (shouldn't happen -- parse catches this) */
goto err; goto err;
@@ -710,6 +723,21 @@ static void blk_alloc(struct XenDevice *xendev)
} }
} }
static void blk_parse_discard(struct XenBlkDev *blkdev)
{
int enable;
blkdev->feature_discard = true;
if (xenstore_read_be_int(&blkdev->xendev, "discard-enable", &enable) == 0) {
blkdev->feature_discard = !!enable;
}
if (blkdev->feature_discard) {
xenstore_write_be_int(&blkdev->xendev, "feature-discard", 1);
}
}
static int blk_init(struct XenDevice *xendev) static int blk_init(struct XenDevice *xendev)
{ {
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
@@ -777,6 +805,8 @@ static int blk_init(struct XenDevice *xendev)
xenstore_write_be_int(&blkdev->xendev, "feature-persistent", 1); xenstore_write_be_int(&blkdev->xendev, "feature-persistent", 1);
xenstore_write_be_int(&blkdev->xendev, "info", info); xenstore_write_be_int(&blkdev->xendev, "info", info);
blk_parse_discard(blkdev);
g_free(directiosafe); g_free(directiosafe);
return 0; return 0;
@@ -812,16 +842,22 @@ static int blk_connect(struct XenDevice *xendev)
qflags |= BDRV_O_RDWR; qflags |= BDRV_O_RDWR;
readonly = false; readonly = false;
} }
if (blkdev->feature_discard) {
qflags |= BDRV_O_UNMAP;
}
/* init qemu block driver */ /* init qemu block driver */
index = (blkdev->xendev.dev - 202 * 256) / 16; index = (blkdev->xendev.dev - 202 * 256) / 16;
blkdev->dinfo = drive_get(IF_XEN, 0, index); blkdev->dinfo = drive_get(IF_XEN, 0, index);
if (!blkdev->dinfo) { if (!blkdev->dinfo) {
Error *local_err = NULL;
/* setup via xenbus -> create new block driver instance */ /* setup via xenbus -> create new block driver instance */
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n"); xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
blkdev->bs = bdrv_new(blkdev->dev); blkdev->bs = bdrv_new(blkdev->dev, &local_err);
if (local_err) {
blkdev->bs = NULL;
}
if (blkdev->bs) { if (blkdev->bs) {
Error *local_err = NULL;
BlockDriver *drv = bdrv_find_whitelisted_format(blkdev->fileproto, BlockDriver *drv = bdrv_find_whitelisted_format(blkdev->fileproto,
readonly); readonly);
if (bdrv_open(&blkdev->bs, blkdev->filename, NULL, NULL, qflags, if (bdrv_open(&blkdev->bs, blkdev->filename, NULL, NULL, qflags,

View File

@@ -338,13 +338,13 @@ PropertyInfo qdev_prop_vlan = {
int qdev_prop_set_drive(DeviceState *dev, const char *name, int qdev_prop_set_drive(DeviceState *dev, const char *name,
BlockDriverState *value) BlockDriverState *value)
{ {
Error *errp = NULL; Error *err = NULL;
const char *bdrv_name = value ? bdrv_get_device_name(value) : ""; const char *bdrv_name = value ? bdrv_get_device_name(value) : "";
object_property_set_str(OBJECT(dev), bdrv_name, object_property_set_str(OBJECT(dev), bdrv_name,
name, &errp); name, &err);
if (errp) { if (err) {
qerror_report_err(errp); qerror_report_err(err);
error_free(errp); error_free(err);
return -1; return -1;
} }
return 0; return 0;

View File

@@ -587,8 +587,9 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
/* We rely on power-of-2 blocksizes for bitmasks */ /* We rely on power-of-2 blocksizes for bitmasks */
if ((value & (value - 1)) != 0) { if ((value & (value - 1)) != 0) {
error_set(errp, QERR_PROPERTY_VALUE_NOT_POWER_OF_2, error_setg(errp,
dev->id?:"", name, (int64_t)value); "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2",
dev->id ?: "", name, (int64_t)value);
return; return;
} }
@@ -750,6 +751,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque; Property *prop = opaque;
uint32_t *alenptr = qdev_get_prop_ptr(dev, prop); uint32_t *alenptr = qdev_get_prop_ptr(dev, prop);
void **arrayptr = (void *)dev + prop->arrayoffset; void **arrayptr = (void *)dev + prop->arrayoffset;
Error *local_err = NULL;
void *eltptr; void *eltptr;
const char *arrayname; const char *arrayname;
int i; int i;
@@ -763,8 +765,9 @@ static void set_prop_arraylen(Object *obj, Visitor *v, void *opaque,
name); name);
return; return;
} }
visit_type_uint32(v, alenptr, name, errp); visit_type_uint32(v, alenptr, name, &local_err);
if (error_is_set(errp)) { if (local_err) {
error_propagate(errp, local_err);
return; return;
} }
if (!*alenptr) { if (!*alenptr) {
@@ -801,8 +804,9 @@ static void set_prop_arraylen(Object *obj, Visitor *v, void *opaque,
arrayprop->prop.info->get, arrayprop->prop.info->get,
arrayprop->prop.info->set, arrayprop->prop.info->set,
array_element_release, array_element_release,
arrayprop, errp); arrayprop, &local_err);
if (error_is_set(errp)) { if (local_err) {
error_propagate(errp, local_err);
return; return;
} }
} }
@@ -853,7 +857,7 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
{ {
switch (ret) { switch (ret) {
case -EEXIST: case -EEXIST:
error_set(errp, QERR_PROPERTY_VALUE_IN_USE, error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
object_get_typename(OBJECT(dev)), prop->name, value); object_get_typename(OBJECT(dev)), prop->name, value);
break; break;
default: default:
@@ -862,7 +866,7 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
object_get_typename(OBJECT(dev)), prop->name, value); object_get_typename(OBJECT(dev)), prop->name, value);
break; break;
case -ENOENT: case -ENOENT:
error_set(errp, QERR_PROPERTY_VALUE_NOT_FOUND, error_setg(errp, "Property '%s.%s' can't find value '%s'",
object_get_typename(OBJECT(dev)), prop->name, value); object_get_typename(OBJECT(dev)), prop->name, value);
break; break;
case 0: case 0:

View File

@@ -174,14 +174,14 @@ int qdev_init(DeviceState *dev)
return 0; return 0;
} }
static void device_realize(DeviceState *dev, Error **err) static void device_realize(DeviceState *dev, Error **errp)
{ {
DeviceClass *dc = DEVICE_GET_CLASS(dev); DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dc->init) { if (dc->init) {
int rc = dc->init(dev); int rc = dc->init(dev);
if (rc < 0) { if (rc < 0) {
error_setg(err, "Device initialization failed."); error_setg(errp, "Device initialization failed.");
return; return;
} }
} }
@@ -504,14 +504,14 @@ static void bus_unparent(Object *obj)
} }
} }
static bool bus_get_realized(Object *obj, Error **err) static bool bus_get_realized(Object *obj, Error **errp)
{ {
BusState *bus = BUS(obj); BusState *bus = BUS(obj);
return bus->realized; return bus->realized;
} }
static void bus_set_realized(Object *obj, bool value, Error **err) static void bus_set_realized(Object *obj, bool value, Error **errp)
{ {
BusState *bus = BUS(obj); BusState *bus = BUS(obj);
BusClass *bc = BUS_GET_CLASS(bus); BusClass *bc = BUS_GET_CLASS(bus);
@@ -540,7 +540,7 @@ static void bus_set_realized(Object *obj, bool value, Error **err)
return; return;
error: error:
error_propagate(err, local_err); error_propagate(errp, local_err);
} }
void qbus_create_inplace(void *bus, size_t size, const char *typename, void qbus_create_inplace(void *bus, size_t size, const char *typename,
@@ -660,8 +660,8 @@ static void qdev_get_legacy_property(Object *obj, Visitor *v, void *opaque,
* Legacy properties are string versions of other OOM properties. The format * Legacy properties are string versions of other OOM properties. The format
* of the string depends on the property type. * of the string depends on the property type.
*/ */
void qdev_property_add_legacy(DeviceState *dev, Property *prop, static void qdev_property_add_legacy(DeviceState *dev, Property *prop,
Error **errp) Error **errp)
{ {
gchar *name; gchar *name;
@@ -724,13 +724,13 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
} }
} }
static bool device_get_realized(Object *obj, Error **err) static bool device_get_realized(Object *obj, Error **errp)
{ {
DeviceState *dev = DEVICE(obj); DeviceState *dev = DEVICE(obj);
return dev->realized; return dev->realized;
} }
static void device_set_realized(Object *obj, bool value, Error **err) static void device_set_realized(Object *obj, bool value, Error **errp)
{ {
DeviceState *dev = DEVICE(obj); DeviceState *dev = DEVICE(obj);
DeviceClass *dc = DEVICE_GET_CLASS(dev); DeviceClass *dc = DEVICE_GET_CLASS(dev);
@@ -738,7 +738,7 @@ static void device_set_realized(Object *obj, bool value, Error **err)
Error *local_err = NULL; Error *local_err = NULL;
if (dev->hotplugged && !dc->hotpluggable) { if (dev->hotplugged && !dc->hotpluggable) {
error_set(err, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj)); error_set(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
return; return;
} }
@@ -797,14 +797,14 @@ static void device_set_realized(Object *obj, bool value, Error **err)
} }
if (local_err != NULL) { if (local_err != NULL) {
error_propagate(err, local_err); error_propagate(errp, local_err);
return; return;
} }
dev->realized = value; dev->realized = value;
} }
static bool device_get_hotpluggable(Object *obj, Error **err) static bool device_get_hotpluggable(Object *obj, Error **errp)
{ {
DeviceClass *dc = DEVICE_GET_CLASS(obj); DeviceClass *dc = DEVICE_GET_CLASS(obj);
DeviceState *dev = DEVICE(obj); DeviceState *dev = DEVICE(obj);

View File

@@ -2913,7 +2913,7 @@ static void isa_cirrus_vga_realizefn(DeviceState *dev, Error **errp)
ISACirrusVGAState *d = ISA_CIRRUS_VGA(dev); ISACirrusVGAState *d = ISA_CIRRUS_VGA(dev);
VGACommonState *s = &d->cirrus_vga.vga; VGACommonState *s = &d->cirrus_vga.vga;
vga_common_init(s, OBJECT(dev)); vga_common_init(s, OBJECT(dev), true);
cirrus_init_common(&d->cirrus_vga, OBJECT(dev), CIRRUS_ID_CLGD5430, 0, cirrus_init_common(&d->cirrus_vga, OBJECT(dev), CIRRUS_ID_CLGD5430, 0,
isa_address_space(isadev), isa_address_space(isadev),
isa_address_space_io(isadev)); isa_address_space_io(isadev));
@@ -2960,7 +2960,7 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
int16_t device_id = pc->device_id; int16_t device_id = pc->device_id;
/* setup VGA */ /* setup VGA */
vga_common_init(&s->vga, OBJECT(dev)); vga_common_init(&s->vga, OBJECT(dev), true);
cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev), cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev),
pci_address_space_io(dev)); pci_address_space_io(dev));
s->vga.con = graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s->vga); s->vga.con = graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s->vga);

View File

@@ -2055,19 +2055,18 @@ static int qxl_init_primary(PCIDevice *dev)
{ {
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev); PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
VGACommonState *vga = &qxl->vga; VGACommonState *vga = &qxl->vga;
PortioList *qxl_vga_port_list = g_new(PortioList, 1);
int rc; int rc;
qxl->id = 0; qxl->id = 0;
qxl_init_ramsize(qxl); qxl_init_ramsize(qxl);
vga->vram_size_mb = qxl->vga.vram_size >> 20; vga->vram_size_mb = qxl->vga.vram_size >> 20;
vga_common_init(vga, OBJECT(dev)); vga_common_init(vga, OBJECT(dev), true);
vga_init(vga, OBJECT(dev), vga_init(vga, OBJECT(dev),
pci_address_space(dev), pci_address_space_io(dev), false); pci_address_space(dev), pci_address_space_io(dev), false);
portio_list_init(qxl_vga_port_list, OBJECT(dev), qxl_vga_portio_list, portio_list_init(&qxl->vga_port_list, OBJECT(dev), qxl_vga_portio_list,
vga, "vga"); vga, "vga");
portio_list_set_flush_coalesced(qxl_vga_port_list); portio_list_set_flush_coalesced(&qxl->vga_port_list);
portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0); portio_list_add(&qxl->vga_port_list, pci_address_space_io(dev), 0x3b0);
vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl);
qemu_spice_display_init_common(&qxl->ssd); qemu_spice_display_init_common(&qxl->ssd);

View File

@@ -32,6 +32,7 @@ enum qxl_mode {
typedef struct PCIQXLDevice { typedef struct PCIQXLDevice {
PCIDevice pci; PCIDevice pci;
PortioList vga_port_list;
SimpleSpiceDisplay ssd; SimpleSpiceDisplay ssd;
int id; int id;
uint32_t debug; uint32_t debug;

View File

@@ -312,18 +312,42 @@ static int ssd0323_load(QEMUFile *f, void *opaque, int version_id)
return -EINVAL; return -EINVAL;
s->cmd_len = qemu_get_be32(f); s->cmd_len = qemu_get_be32(f);
if (s->cmd_len < 0 || s->cmd_len > ARRAY_SIZE(s->cmd_data)) {
return -EINVAL;
}
s->cmd = qemu_get_be32(f); s->cmd = qemu_get_be32(f);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
s->cmd_data[i] = qemu_get_be32(f); s->cmd_data[i] = qemu_get_be32(f);
s->row = qemu_get_be32(f); s->row = qemu_get_be32(f);
if (s->row < 0 || s->row >= 80) {
return -EINVAL;
}
s->row_start = qemu_get_be32(f); s->row_start = qemu_get_be32(f);
if (s->row_start < 0 || s->row_start >= 80) {
return -EINVAL;
}
s->row_end = qemu_get_be32(f); s->row_end = qemu_get_be32(f);
if (s->row_end < 0 || s->row_end >= 80) {
return -EINVAL;
}
s->col = qemu_get_be32(f); s->col = qemu_get_be32(f);
if (s->col < 0 || s->col >= 64) {
return -EINVAL;
}
s->col_start = qemu_get_be32(f); s->col_start = qemu_get_be32(f);
if (s->col_start < 0 || s->col_start >= 64) {
return -EINVAL;
}
s->col_end = qemu_get_be32(f); s->col_end = qemu_get_be32(f);
if (s->col_end < 0 || s->col_end >= 64) {
return -EINVAL;
}
s->redraw = qemu_get_be32(f); s->redraw = qemu_get_be32(f);
s->remap = qemu_get_be32(f); s->remap = qemu_get_be32(f);
s->mode = qemu_get_be32(f); s->mode = qemu_get_be32(f);
if (s->mode != SSD0323_CMD && s->mode != SSD0323_DATA) {
return -EINVAL;
}
qemu_get_buffer(f, s->framebuffer, sizeof(s->framebuffer)); qemu_get_buffer(f, s->framebuffer, sizeof(s->framebuffer));
ss->cs = qemu_get_be32(f); ss->cs = qemu_get_be32(f);

View File

@@ -132,7 +132,7 @@ int isa_vga_mm_init(hwaddr vram_base,
s = g_malloc0(sizeof(*s)); s = g_malloc0(sizeof(*s));
s->vga.vram_size_mb = VGA_RAM_SIZE >> 20; s->vga.vram_size_mb = VGA_RAM_SIZE >> 20;
vga_common_init(&s->vga, NULL); vga_common_init(&s->vga, NULL, true);
vga_mm_init(s, vram_base, ctrl_base, it_shift, address_space); vga_mm_init(s, vram_base, ctrl_base, it_shift, address_space);
s->vga.con = graphic_console_init(NULL, 0, s->vga.hw_ops, s); s->vga.con = graphic_console_init(NULL, 0, s->vga.hw_ops, s);

View File

@@ -56,7 +56,7 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
MemoryRegion *vga_io_memory; MemoryRegion *vga_io_memory;
const MemoryRegionPortio *vga_ports, *vbe_ports; const MemoryRegionPortio *vga_ports, *vbe_ports;
vga_common_init(s, OBJECT(dev)); vga_common_init(s, OBJECT(dev), true);
s->legacy_address_space = isa_address_space(isadev); s->legacy_address_space = isa_address_space(isadev);
vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports); vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports);
isa_register_portio_list(isadev, 0x3b0, vga_ports, s, "vga"); isa_register_portio_list(isadev, 0x3b0, vga_ports, s, "vga");

View File

@@ -147,7 +147,7 @@ static int pci_std_vga_initfn(PCIDevice *dev)
VGACommonState *s = &d->vga; VGACommonState *s = &d->vga;
/* vga + console init */ /* vga + console init */
vga_common_init(s, OBJECT(dev)); vga_common_init(s, OBJECT(dev), true);
vga_init(s, OBJECT(dev), pci_address_space(dev), pci_address_space_io(dev), vga_init(s, OBJECT(dev), pci_address_space(dev), pci_address_space_io(dev),
true); true);
@@ -179,12 +179,51 @@ static int pci_std_vga_initfn(PCIDevice *dev)
return 0; return 0;
} }
static int pci_secondary_vga_initfn(PCIDevice *dev)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
VGACommonState *s = &d->vga;
/* vga + console init */
vga_common_init(s, OBJECT(dev), false);
s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s);
/* mmio bar */
memory_region_init(&d->mmio, OBJECT(dev), "vga.mmio", 4096);
memory_region_init_io(&d->ioport, OBJECT(dev), &pci_vga_ioport_ops, d,
"vga ioports remapped", PCI_VGA_IOPORT_SIZE);
memory_region_init_io(&d->bochs, OBJECT(dev), &pci_vga_bochs_ops, d,
"bochs dispi interface", PCI_VGA_BOCHS_SIZE);
memory_region_add_subregion(&d->mmio, PCI_VGA_IOPORT_OFFSET,
&d->ioport);
memory_region_add_subregion(&d->mmio, PCI_VGA_BOCHS_OFFSET,
&d->bochs);
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
return 0;
}
static void pci_secondary_vga_reset(DeviceState *dev)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev.qdev, dev);
vga_common_reset(&d->vga);
}
static Property vga_pci_properties[] = { static Property vga_pci_properties[] = {
DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16), DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
DEFINE_PROP_BIT("mmio", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_MMIO, true), DEFINE_PROP_BIT("mmio", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_MMIO, true),
DEFINE_PROP_END_OF_LIST(), DEFINE_PROP_END_OF_LIST(),
}; };
static Property secondary_pci_properties[] = {
DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
DEFINE_PROP_END_OF_LIST(),
};
static void vga_class_init(ObjectClass *klass, void *data) static void vga_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
@@ -201,6 +240,20 @@ static void vga_class_init(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
} }
static void secondary_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = pci_secondary_vga_initfn;
k->vendor_id = PCI_VENDOR_ID_QEMU;
k->device_id = PCI_DEVICE_ID_QEMU_VGA;
k->class_id = PCI_CLASS_DISPLAY_OTHER;
dc->vmsd = &vmstate_vga_pci;
dc->props = secondary_pci_properties;
dc->reset = pci_secondary_vga_reset;
}
static const TypeInfo vga_info = { static const TypeInfo vga_info = {
.name = "VGA", .name = "VGA",
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
@@ -208,9 +261,17 @@ static const TypeInfo vga_info = {
.class_init = vga_class_init, .class_init = vga_class_init,
}; };
static const TypeInfo secondary_info = {
.name = "secondary-vga",
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCIVGAState),
.class_init = secondary_class_init,
};
static void vga_register_types(void) static void vga_register_types(void)
{ {
type_register_static(&vga_info); type_register_static(&vga_info);
type_register_static(&secondary_info);
} }
type_init(vga_register_types) type_init(vga_register_types)

View File

@@ -171,6 +171,10 @@ static void vga_update_memory_access(VGACommonState *s)
MemoryRegion *region, *old_region = s->chain4_alias; MemoryRegion *region, *old_region = s->chain4_alias;
hwaddr base, offset, size; hwaddr base, offset, size;
if (s->legacy_address_space == NULL) {
return;
}
s->chain4_alias = NULL; s->chain4_alias = NULL;
if ((s->sr[VGA_SEQ_PLANE_WRITE] & VGA_SR02_ALL_PLANES) == if ((s->sr[VGA_SEQ_PLANE_WRITE] & VGA_SR02_ALL_PLANES) ==
@@ -2252,7 +2256,7 @@ static const GraphicHwOps vga_ops = {
.text_update = vga_update_text, .text_update = vga_update_text,
}; };
void vga_common_init(VGACommonState *s, Object *obj) void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate)
{ {
int i, j, v, b; int i, j, v, b;
@@ -2289,7 +2293,7 @@ void vga_common_init(VGACommonState *s, Object *obj)
s->is_vbe_vmstate = 1; s->is_vbe_vmstate = 1;
memory_region_init_ram(&s->vram, obj, "vga.vram", s->vram_size); memory_region_init_ram(&s->vram, obj, "vga.vram", s->vram_size);
vmstate_register_ram_global(&s->vram); vmstate_register_ram(&s->vram, global_vmstate ? NULL : DEVICE(obj));
xen_register_framebuffer(&s->vram); xen_register_framebuffer(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram); s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
s->get_bpp = vga_get_bpp; s->get_bpp = vga_get_bpp;
@@ -2351,8 +2355,6 @@ void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
{ {
MemoryRegion *vga_io_memory; MemoryRegion *vga_io_memory;
const MemoryRegionPortio *vga_ports, *vbe_ports; const MemoryRegionPortio *vga_ports, *vbe_ports;
PortioList *vga_port_list = g_new(PortioList, 1);
PortioList *vbe_port_list = g_new(PortioList, 1);
qemu_register_reset(vga_reset, s); qemu_register_reset(vga_reset, s);
@@ -2367,13 +2369,13 @@ void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
1); 1);
memory_region_set_coalescing(vga_io_memory); memory_region_set_coalescing(vga_io_memory);
if (init_vga_ports) { if (init_vga_ports) {
portio_list_init(vga_port_list, obj, vga_ports, s, "vga"); portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga");
portio_list_set_flush_coalesced(vga_port_list); portio_list_set_flush_coalesced(&s->vga_port_list);
portio_list_add(vga_port_list, address_space_io, 0x3b0); portio_list_add(&s->vga_port_list, address_space_io, 0x3b0);
} }
if (vbe_ports) { if (vbe_ports) {
portio_list_init(vbe_port_list, obj, vbe_ports, s, "vbe"); portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe");
portio_list_add(vbe_port_list, address_space_io, 0x1ce); portio_list_add(&s->vbe_port_list, address_space_io, 0x1ce);
} }
} }

View File

@@ -124,6 +124,8 @@ typedef struct VGACommonState {
void (*get_resolution)(struct VGACommonState *s, void (*get_resolution)(struct VGACommonState *s,
int *pwidth, int *pwidth,
int *pheight); int *pheight);
PortioList vga_port_list;
PortioList vbe_port_list;
/* bochs vbe state */ /* bochs vbe state */
uint16_t vbe_index; uint16_t vbe_index;
uint16_t vbe_regs[VBE_DISPI_INDEX_NB]; uint16_t vbe_regs[VBE_DISPI_INDEX_NB];
@@ -177,7 +179,7 @@ static inline int c6_to_8(int v)
return (v << 2) | (b << 1) | b; return (v << 2) | (b << 1) | b;
} }
void vga_common_init(VGACommonState *s, Object *obj); void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate);
void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space, void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
MemoryRegion *address_space_io, bool init_vga_ports); MemoryRegion *address_space_io, bool init_vga_ports);
MemoryRegion *vga_init_io(VGACommonState *s, Object *obj, MemoryRegion *vga_init_io(VGACommonState *s, Object *obj,

View File

@@ -1207,7 +1207,7 @@ static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s,
vmstate_register_ram_global(&s->fifo_ram); vmstate_register_ram_global(&s->fifo_ram);
s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram); s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram);
vga_common_init(&s->vga, OBJECT(dev)); vga_common_init(&s->vga, OBJECT(dev), true);
vga_init(&s->vga, OBJECT(dev), address_space, io, true); vga_init(&s->vga, OBJECT(dev), address_space, io, true);
vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga); vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
s->new_depth = 32; s->new_depth = 32;

View File

@@ -39,6 +39,7 @@ do { fprintf(stderr, "i82374 ERROR: " fmt , ## __VA_ARGS__); } while (0)
typedef struct I82374State { typedef struct I82374State {
uint8_t commands[8]; uint8_t commands[8];
qemu_irq out; qemu_irq out;
PortioList port_list;
} I82374State; } I82374State;
static const VMStateDescription vmstate_i82374 = { static const VMStateDescription vmstate_i82374 = {
@@ -137,10 +138,10 @@ static void i82374_isa_realize(DeviceState *dev, Error **errp)
{ {
ISAi82374State *isa = I82374(dev); ISAi82374State *isa = I82374(dev);
I82374State *s = &isa->state; I82374State *s = &isa->state;
PortioList *port_list = g_new(PortioList, 1);
portio_list_init(port_list, OBJECT(isa), i82374_portio_list, s, "i82374"); portio_list_init(&s->port_list, OBJECT(isa), i82374_portio_list, s,
portio_list_add(port_list, isa_address_space_io(&isa->parent_obj), "i82374");
portio_list_add(&s->port_list, isa_address_space_io(&isa->parent_obj),
isa->iobase); isa->iobase);
i82374_realize(s, errp); i82374_realize(s, errp);

View File

@@ -534,24 +534,24 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
XilinxAXIDMAStreamSlave *ds = XILINX_AXI_DMA_DATA_STREAM(&s->rx_data_dev); XilinxAXIDMAStreamSlave *ds = XILINX_AXI_DMA_DATA_STREAM(&s->rx_data_dev);
XilinxAXIDMAStreamSlave *cs = XILINX_AXI_DMA_CONTROL_STREAM( XilinxAXIDMAStreamSlave *cs = XILINX_AXI_DMA_CONTROL_STREAM(
&s->rx_control_dev); &s->rx_control_dev);
Error *local_errp = NULL; Error *local_err = NULL;
object_property_add_link(OBJECT(ds), "dma", TYPE_XILINX_AXI_DMA, object_property_add_link(OBJECT(ds), "dma", TYPE_XILINX_AXI_DMA,
(Object **)&ds->dma, (Object **)&ds->dma,
object_property_allow_set_link, object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, OBJ_PROP_LINK_UNREF_ON_RELEASE,
&local_errp); &local_err);
object_property_add_link(OBJECT(cs), "dma", TYPE_XILINX_AXI_DMA, object_property_add_link(OBJECT(cs), "dma", TYPE_XILINX_AXI_DMA,
(Object **)&cs->dma, (Object **)&cs->dma,
object_property_allow_set_link, object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, OBJ_PROP_LINK_UNREF_ON_RELEASE,
&local_errp); &local_err);
if (local_errp) { if (local_err) {
goto xilinx_axidma_realize_fail; goto xilinx_axidma_realize_fail;
} }
object_property_set_link(OBJECT(ds), OBJECT(s), "dma", &local_errp); object_property_set_link(OBJECT(ds), OBJECT(s), "dma", &local_err);
object_property_set_link(OBJECT(cs), OBJECT(s), "dma", &local_errp); object_property_set_link(OBJECT(cs), OBJECT(s), "dma", &local_err);
if (local_errp) { if (local_err) {
goto xilinx_axidma_realize_fail; goto xilinx_axidma_realize_fail;
} }
@@ -567,7 +567,7 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
xilinx_axidma_realize_fail: xilinx_axidma_realize_fail:
if (!*errp) { if (!*errp) {
*errp = local_errp; *errp = local_err;
} }
} }

View File

@@ -203,6 +203,15 @@ static bool is_version_0 (void *opaque, int version_id)
return version_id == 0; return version_id == 0;
} }
static bool vmstate_scoop_validate(void *opaque, int version_id)
{
ScoopInfo *s = opaque;
return !(s->prev_level & 0xffff0000) &&
!(s->gpio_level & 0xffff0000) &&
!(s->gpio_dir & 0xffff0000);
}
static const VMStateDescription vmstate_scoop_regs = { static const VMStateDescription vmstate_scoop_regs = {
.name = "scoop", .name = "scoop",
.version_id = 1, .version_id = 1,
@@ -215,6 +224,7 @@ static const VMStateDescription vmstate_scoop_regs = {
VMSTATE_UINT32(gpio_level, ScoopInfo), VMSTATE_UINT32(gpio_level, ScoopInfo),
VMSTATE_UINT32(gpio_dir, ScoopInfo), VMSTATE_UINT32(gpio_dir, ScoopInfo),
VMSTATE_UINT32(prev_level, ScoopInfo), VMSTATE_UINT32(prev_level, ScoopInfo),
VMSTATE_VALIDATE("irq levels are 16 bit", vmstate_scoop_validate),
VMSTATE_UINT16(mcr, ScoopInfo), VMSTATE_UINT16(mcr, ScoopInfo),
VMSTATE_UINT16(cdr, ScoopInfo), VMSTATE_UINT16(cdr, ScoopInfo),
VMSTATE_UINT16(ccr, ScoopInfo), VMSTATE_UINT16(ccr, ScoopInfo),

View File

@@ -60,59 +60,78 @@ static void smb_transaction(PMSMBus *s)
uint8_t cmd = s->smb_cmd; uint8_t cmd = s->smb_cmd;
uint8_t addr = s->smb_addr >> 1; uint8_t addr = s->smb_addr >> 1;
I2CBus *bus = s->smbus; I2CBus *bus = s->smbus;
int ret;
SMBUS_DPRINTF("SMBus trans addr=0x%02x prot=0x%02x\n", addr, prot); SMBUS_DPRINTF("SMBus trans addr=0x%02x prot=0x%02x\n", addr, prot);
/* Transaction isn't exec if STS_DEV_ERR bit set */ /* Transaction isn't exec if STS_DEV_ERR bit set */
if ((s->smb_stat & STS_DEV_ERR) != 0) { if ((s->smb_stat & STS_DEV_ERR) != 0) {
goto error; goto error;
} }
switch(prot) { switch(prot) {
case 0x0: case 0x0:
smbus_quick_command(bus, addr, read); ret = smbus_quick_command(bus, addr, read);
s->smb_stat |= STS_BYTE_DONE | STS_INTR; goto done;
break;
case 0x1: case 0x1:
if (read) { if (read) {
s->smb_data0 = smbus_receive_byte(bus, addr); ret = smbus_receive_byte(bus, addr);
goto data8;
} else { } else {
smbus_send_byte(bus, addr, cmd); ret = smbus_send_byte(bus, addr, cmd);
goto done;
} }
s->smb_stat |= STS_BYTE_DONE | STS_INTR;
break;
case 0x2: case 0x2:
if (read) { if (read) {
s->smb_data0 = smbus_read_byte(bus, addr, cmd); ret = smbus_read_byte(bus, addr, cmd);
goto data8;
} else { } else {
smbus_write_byte(bus, addr, cmd, s->smb_data0); ret = smbus_write_byte(bus, addr, cmd, s->smb_data0);
goto done;
} }
s->smb_stat |= STS_BYTE_DONE | STS_INTR;
break; break;
case 0x3: case 0x3:
if (read) { if (read) {
uint16_t val; ret = smbus_read_word(bus, addr, cmd);
val = smbus_read_word(bus, addr, cmd); goto data16;
s->smb_data0 = val;
s->smb_data1 = val >> 8;
} else { } else {
smbus_write_word(bus, addr, cmd, (s->smb_data1 << 8) | s->smb_data0); ret = smbus_write_word(bus, addr, cmd, (s->smb_data1 << 8) | s->smb_data0);
goto done;
} }
s->smb_stat |= STS_BYTE_DONE | STS_INTR;
break; break;
case 0x5: case 0x5:
if (read) { if (read) {
s->smb_data0 = smbus_read_block(bus, addr, cmd, s->smb_data); ret = smbus_read_block(bus, addr, cmd, s->smb_data);
goto data8;
} else { } else {
smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0); ret = smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0);
goto done;
} }
s->smb_stat |= STS_BYTE_DONE | STS_INTR;
break; break;
default: default:
goto error; goto error;
} }
abort();
data16:
if (ret < 0) {
goto error;
}
s->smb_data1 = ret >> 8;
data8:
if (ret < 0) {
goto error;
}
s->smb_data0 = ret;
done:
if (ret < 0) {
goto error;
}
s->smb_stat |= STS_BYTE_DONE | STS_INTR;
return; return;
error: error:
s->smb_stat |= STS_DEV_ERR; s->smb_stat |= STS_DEV_ERR;
return;
} }
static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,

View File

@@ -208,34 +208,44 @@ static int smbus_device_init(I2CSlave *i2c)
} }
/* Master device commands. */ /* Master device commands. */
void smbus_quick_command(I2CBus *bus, uint8_t addr, int read) int smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
{ {
i2c_start_transfer(bus, addr, read); if (i2c_start_transfer(bus, addr, read)) {
return -1;
}
i2c_end_transfer(bus); i2c_end_transfer(bus);
return 0;
} }
uint8_t smbus_receive_byte(I2CBus *bus, uint8_t addr) int smbus_receive_byte(I2CBus *bus, uint8_t addr)
{ {
uint8_t data; uint8_t data;
i2c_start_transfer(bus, addr, 1); if (i2c_start_transfer(bus, addr, 1)) {
return -1;
}
data = i2c_recv(bus); data = i2c_recv(bus);
i2c_nack(bus); i2c_nack(bus);
i2c_end_transfer(bus); i2c_end_transfer(bus);
return data; return data;
} }
void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data) int smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data)
{ {
i2c_start_transfer(bus, addr, 0); if (i2c_start_transfer(bus, addr, 0)) {
return -1;
}
i2c_send(bus, data); i2c_send(bus, data);
i2c_end_transfer(bus); i2c_end_transfer(bus);
return 0;
} }
uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command) int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
{ {
uint8_t data; uint8_t data;
i2c_start_transfer(bus, addr, 0); if (i2c_start_transfer(bus, addr, 0)) {
return -1;
}
i2c_send(bus, command); i2c_send(bus, command);
i2c_start_transfer(bus, addr, 1); i2c_start_transfer(bus, addr, 1);
data = i2c_recv(bus); data = i2c_recv(bus);
@@ -244,18 +254,23 @@ uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
return data; return data;
} }
void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data) int smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data)
{ {
i2c_start_transfer(bus, addr, 0); if (i2c_start_transfer(bus, addr, 0)) {
return -1;
}
i2c_send(bus, command); i2c_send(bus, command);
i2c_send(bus, data); i2c_send(bus, data);
i2c_end_transfer(bus); i2c_end_transfer(bus);
return 0;
} }
uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command) int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
{ {
uint16_t data; uint16_t data;
i2c_start_transfer(bus, addr, 0); if (i2c_start_transfer(bus, addr, 0)) {
return -1;
}
i2c_send(bus, command); i2c_send(bus, command);
i2c_start_transfer(bus, addr, 1); i2c_start_transfer(bus, addr, 1);
data = i2c_recv(bus); data = i2c_recv(bus);
@@ -265,13 +280,16 @@ uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
return data; return data;
} }
void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data) int smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data)
{ {
i2c_start_transfer(bus, addr, 0); if (i2c_start_transfer(bus, addr, 0)) {
return -1;
}
i2c_send(bus, command); i2c_send(bus, command);
i2c_send(bus, data & 0xff); i2c_send(bus, data & 0xff);
i2c_send(bus, data >> 8); i2c_send(bus, data >> 8);
i2c_end_transfer(bus); i2c_end_transfer(bus);
return 0;
} }
int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data) int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data)
@@ -279,33 +297,41 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data)
int len; int len;
int i; int i;
i2c_start_transfer(bus, addr, 0); if (i2c_start_transfer(bus, addr, 0)) {
return -1;
}
i2c_send(bus, command); i2c_send(bus, command);
i2c_start_transfer(bus, addr, 1); i2c_start_transfer(bus, addr, 1);
len = i2c_recv(bus); len = i2c_recv(bus);
if (len > 32) if (len > 32) {
len = 0; len = 0;
for (i = 0; i < len; i++) }
for (i = 0; i < len; i++) {
data[i] = i2c_recv(bus); data[i] = i2c_recv(bus);
}
i2c_nack(bus); i2c_nack(bus);
i2c_end_transfer(bus); i2c_end_transfer(bus);
return len; return len;
} }
void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
int len) int len)
{ {
int i; int i;
if (len > 32) if (len > 32)
len = 32; len = 32;
i2c_start_transfer(bus, addr, 0); if (i2c_start_transfer(bus, addr, 0)) {
return -1;
}
i2c_send(bus, command); i2c_send(bus, command);
i2c_send(bus, len); i2c_send(bus, len);
for (i = 0; i < len; i++) for (i = 0; i < len; i++) {
i2c_send(bus, data[i]); i2c_send(bus, data[i]);
}
i2c_end_transfer(bus); i2c_end_transfer(bus);
return 0;
} }
static void smbus_device_class_init(ObjectClass *klass, void *data) static void smbus_device_class_init(ObjectClass *klass, void *data)

View File

@@ -71,7 +71,7 @@ static void eeprom_write_data(SMBusDevice *dev, uint8_t cmd, uint8_t *buf, int l
printf("eeprom_write_byte: addr=0x%02x cmd=0x%02x val=0x%02x\n", printf("eeprom_write_byte: addr=0x%02x cmd=0x%02x val=0x%02x\n",
dev->i2c.address, cmd, buf[0]); dev->i2c.address, cmd, buf[0]);
#endif #endif
/* An page write operation is not a valid SMBus command. /* A page write operation is not a valid SMBus command.
It is a block write without a length byte. Fortunately we It is a block write without a length byte. Fortunately we
get the full block anyway. */ get the full block anyway. */
/* TODO: Should this set the current location? */ /* TODO: Should this set the current location? */

View File

@@ -2,7 +2,7 @@ obj-$(CONFIG_KVM) += kvm/
obj-y += multiboot.o smbios.o obj-y += multiboot.o smbios.o
obj-y += pc.o pc_piix.o pc_q35.o obj-y += pc.o pc_piix.o pc_q35.o
obj-y += pc_sysfw.o obj-y += pc_sysfw.o
obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-$(CONFIG_XEN) += ../xenpv/ xen/
obj-y += kvmvapic.o obj-y += kvmvapic.o
obj-y += acpi-build.o obj-y += acpi-build.o

View File

@@ -156,18 +156,21 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
} else { } else {
pm->s3_disabled = false; pm->s3_disabled = false;
} }
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL); o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);
if (o) { if (o) {
pm->s4_disabled = qint_get_int(qobject_to_qint(o)); pm->s4_disabled = qint_get_int(qobject_to_qint(o));
} else { } else {
pm->s4_disabled = false; pm->s4_disabled = false;
} }
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL); o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);
if (o) { if (o) {
pm->s4_val = qint_get_int(qobject_to_qint(o)); pm->s4_val = qint_get_int(qobject_to_qint(o));
} else { } else {
pm->s4_val = false; pm->s4_val = false;
} }
qobject_decref(o);
/* Fill in mandatory properties */ /* Fill in mandatory properties */
pm->sci_int = object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NULL); pm->sci_int = object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NULL);
@@ -973,6 +976,7 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
} }
} }
qobject_decref(bsel);
build_free_array(bus_table); build_free_array(bus_table);
build_pci_bus_state_cleanup(child); build_pci_bus_state_cleanup(child);
g_free(child); g_free(child);
@@ -1362,10 +1366,12 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
return false; return false;
} }
mcfg->mcfg_base = qint_get_int(qobject_to_qint(o)); mcfg->mcfg_base = qint_get_int(qobject_to_qint(o));
qobject_decref(o);
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL); o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o); assert(o);
mcfg->mcfg_size = qint_get_int(qobject_to_qint(o)); mcfg->mcfg_size = qint_get_int(qobject_to_qint(o));
qobject_decref(o);
return true; return true;
} }
@@ -1410,15 +1416,16 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
/* ACPI tables pointed to by RSDT */ /* ACPI tables pointed to by RSDT */
acpi_add_table(table_offsets, tables->table_data); acpi_add_table(table_offsets, tables->table_data);
build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt); build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt);
acpi_add_table(table_offsets, tables->table_data);
acpi_add_table(table_offsets, tables->table_data);
build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci, build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci,
guest_info); guest_info);
acpi_add_table(table_offsets, tables->table_data);
build_madt(tables->table_data, tables->linker, &cpu, guest_info);
acpi_add_table(table_offsets, tables->table_data); acpi_add_table(table_offsets, tables->table_data);
build_madt(tables->table_data, tables->linker, &cpu, guest_info);
if (misc.has_hpet) { if (misc.has_hpet) {
acpi_add_table(table_offsets, tables->table_data);
build_hpet(tables->table_data, tables->linker); build_hpet(tables->table_data, tables->linker);
} }
if (guest_info->numa_nodes) { if (guest_info->numa_nodes) {

View File

@@ -394,9 +394,10 @@ static uint8_t pci_find_cap_offset(PCIDevice *d, uint8_t cap, uint8_t start)
return 0; return 0;
} }
static int assigned_dev_register_regions(PCIRegion *io_regions, static void assigned_dev_register_regions(PCIRegion *io_regions,
unsigned long regions_num, unsigned long regions_num,
AssignedDevice *pci_dev) AssignedDevice *pci_dev,
Error **errp)
{ {
uint32_t i; uint32_t i;
PCIRegion *cur_region = io_regions; PCIRegion *cur_region = io_regions;
@@ -425,9 +426,9 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
if (pci_dev->v_addrs[i].u.r_virtbase == MAP_FAILED) { if (pci_dev->v_addrs[i].u.r_virtbase == MAP_FAILED) {
pci_dev->v_addrs[i].u.r_virtbase = NULL; pci_dev->v_addrs[i].u.r_virtbase = NULL;
error_report("%s: Error: Couldn't mmap 0x%" PRIx64 "!", error_setg_errno(errp, errno, "Couldn't mmap 0x%" PRIx64 "!",
__func__, cur_region->base_addr); cur_region->base_addr);
return -1; return;
} }
pci_dev->v_addrs[i].r_size = cur_region->size; pci_dev->v_addrs[i].r_size = cur_region->size;
@@ -496,10 +497,10 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
} }
/* success */ /* success */
return 0;
} }
static int get_real_id(const char *devpath, const char *idname, uint16_t *val) static void get_real_id(const char *devpath, const char *idname, uint16_t *val,
Error **errp)
{ {
FILE *f; FILE *f;
char name[128]; char name[128];
@@ -508,39 +509,39 @@ static int get_real_id(const char *devpath, const char *idname, uint16_t *val)
snprintf(name, sizeof(name), "%s%s", devpath, idname); snprintf(name, sizeof(name), "%s%s", devpath, idname);
f = fopen(name, "r"); f = fopen(name, "r");
if (f == NULL) { if (f == NULL) {
error_report("%s: %s: %m", __func__, name); error_setg_file_open(errp, errno, name);
return -1; return;
} }
if (fscanf(f, "%li\n", &id) == 1) { if (fscanf(f, "%li\n", &id) == 1) {
*val = id; *val = id;
} else { } else {
fclose(f); error_setg(errp, "Failed to parse contents of '%s'", name);
return -1;
} }
fclose(f); fclose(f);
return 0;
} }
static int get_real_vendor_id(const char *devpath, uint16_t *val) static void get_real_vendor_id(const char *devpath, uint16_t *val,
Error **errp)
{ {
return get_real_id(devpath, "vendor", val); get_real_id(devpath, "vendor", val, errp);
} }
static int get_real_device_id(const char *devpath, uint16_t *val) static void get_real_device_id(const char *devpath, uint16_t *val,
Error **errp)
{ {
return get_real_id(devpath, "device", val); get_real_id(devpath, "device", val, errp);
} }
static int get_real_device(AssignedDevice *pci_dev) static void get_real_device(AssignedDevice *pci_dev, Error **errp)
{ {
char dir[128], name[128]; char dir[128], name[128];
int fd, r = 0, v; int fd, r = 0;
FILE *f; FILE *f;
uint64_t start, end, size, flags; uint64_t start, end, size, flags;
uint16_t id; uint16_t id;
PCIRegion *rp; PCIRegion *rp;
PCIDevRegions *dev = &pci_dev->real_device; PCIDevRegions *dev = &pci_dev->real_device;
Error *local_err = NULL;
dev->region_number = 0; dev->region_number = 0;
@@ -551,16 +552,19 @@ static int get_real_device(AssignedDevice *pci_dev)
snprintf(name, sizeof(name), "%sconfig", dir); snprintf(name, sizeof(name), "%sconfig", dir);
if (pci_dev->configfd_name && *pci_dev->configfd_name) { if (pci_dev->configfd_name && *pci_dev->configfd_name) {
dev->config_fd = monitor_handle_fd_param(cur_mon, pci_dev->configfd_name); dev->config_fd = monitor_handle_fd_param2(cur_mon,
if (dev->config_fd < 0) { pci_dev->configfd_name,
return 1; &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
} }
} else { } else {
dev->config_fd = open(name, O_RDWR); dev->config_fd = open(name, O_RDWR);
if (dev->config_fd == -1) { if (dev->config_fd == -1) {
error_report("%s: %s: %m", __func__, name); error_setg_file_open(errp, errno, name);
return 1; return;
} }
} }
again: again:
@@ -570,7 +574,10 @@ again:
if (errno == EINTR || errno == EAGAIN) { if (errno == EINTR || errno == EAGAIN) {
goto again; goto again;
} }
error_report("%s: read failed, errno = %d", __func__, errno); error_setg_errno(errp, errno, "read(\"%s\")",
(pci_dev->configfd_name && *pci_dev->configfd_name) ?
pci_dev->configfd_name : name);
return;
} }
/* Restore or clear multifunction, this is always controlled by qemu */ /* Restore or clear multifunction, this is always controlled by qemu */
@@ -590,8 +597,8 @@ again:
f = fopen(name, "r"); f = fopen(name, "r");
if (f == NULL) { if (f == NULL) {
error_report("%s: %s: %m", __func__, name); error_setg_file_open(errp, errno, name);
return 1; return;
} }
for (r = 0; r < PCI_ROM_SLOT; r++) { for (r = 0; r < PCI_ROM_SLOT; r++) {
@@ -634,17 +641,19 @@ again:
fclose(f); fclose(f);
/* read and fill vendor ID */ /* read and fill vendor ID */
v = get_real_vendor_id(dir, &id); get_real_vendor_id(dir, &id, &local_err);
if (v) { if (local_err) {
return 1; error_propagate(errp, local_err);
return;
} }
pci_dev->dev.config[0] = id & 0xff; pci_dev->dev.config[0] = id & 0xff;
pci_dev->dev.config[1] = (id & 0xff00) >> 8; pci_dev->dev.config[1] = (id & 0xff00) >> 8;
/* read and fill device ID */ /* read and fill device ID */
v = get_real_device_id(dir, &id); get_real_device_id(dir, &id, &local_err);
if (v) { if (local_err) {
return 1; error_propagate(errp, local_err);
return;
} }
pci_dev->dev.config[2] = id & 0xff; pci_dev->dev.config[2] = id & 0xff;
pci_dev->dev.config[3] = (id & 0xff00) >> 8; pci_dev->dev.config[3] = (id & 0xff00) >> 8;
@@ -653,7 +662,6 @@ again:
PCI_COMMAND_MASTER | PCI_COMMAND_INTX_DISABLE); PCI_COMMAND_MASTER | PCI_COMMAND_INTX_DISABLE);
dev->region_number = r; dev->region_number = r;
return 0;
} }
static void free_msi_virqs(AssignedDevice *dev) static void free_msi_virqs(AssignedDevice *dev)
@@ -726,11 +734,17 @@ static void free_assigned_device(AssignedDevice *dev)
free_msi_virqs(dev); free_msi_virqs(dev);
} }
static void assign_failed_examine(AssignedDevice *dev) /* This function tries to determine the cause of the PCI assignment failure. It
* always returns the cause as a dynamically allocated, human readable string.
* If the function fails to determine the cause for any internal reason, then
* the returned string will state that fact.
*/
static char *assign_failed_examine(const AssignedDevice *dev)
{ {
char name[PATH_MAX], dir[PATH_MAX], driver[PATH_MAX] = {}, *ns; char name[PATH_MAX], dir[PATH_MAX], driver[PATH_MAX] = {}, *ns;
uint16_t vendor_id, device_id; uint16_t vendor_id, device_id;
int r; int r;
Error *local_err = NULL;
snprintf(dir, sizeof(dir), "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/", snprintf(dir, sizeof(dir), "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/",
dev->host.domain, dev->host.bus, dev->host.slot, dev->host.domain, dev->host.bus, dev->host.slot,
@@ -751,13 +765,17 @@ static void assign_failed_examine(AssignedDevice *dev)
ns++; ns++;
if (get_real_vendor_id(dir, &vendor_id) || if ((get_real_vendor_id(dir, &vendor_id, &local_err), local_err) ||
get_real_device_id(dir, &device_id)) { (get_real_device_id(dir, &device_id, &local_err), local_err)) {
/* We're already analyzing an assignment error, so we suppress this
* one just like the others above.
*/
error_free(local_err);
goto fail; goto fail;
} }
error_printf("*** The driver '%s' is occupying your device " return g_strdup_printf(
"%04x:%02x:%02x.%x.\n" "*** The driver '%s' is occupying your device %04x:%02x:%02x.%x.\n"
"***\n" "***\n"
"*** You can try the following commands to free it:\n" "*** You can try the following commands to free it:\n"
"***\n" "***\n"
@@ -773,13 +791,11 @@ static void assign_failed_examine(AssignedDevice *dev)
ns, dev->host.domain, dev->host.bus, dev->host.slot, ns, dev->host.domain, dev->host.bus, dev->host.slot,
dev->host.function, vendor_id, device_id); dev->host.function, vendor_id, device_id);
return;
fail: fail:
error_report("Couldn't find out why."); return g_strdup("Couldn't find out why.");
} }
static int assign_device(AssignedDevice *dev) static void assign_device(AssignedDevice *dev, Error **errp)
{ {
uint32_t flags = KVM_DEV_ASSIGN_ENABLE_IOMMU; uint32_t flags = KVM_DEV_ASSIGN_ENABLE_IOMMU;
int r; int r;
@@ -787,15 +803,15 @@ static int assign_device(AssignedDevice *dev)
/* Only pass non-zero PCI segment to capable module */ /* Only pass non-zero PCI segment to capable module */
if (!kvm_check_extension(kvm_state, KVM_CAP_PCI_SEGMENT) && if (!kvm_check_extension(kvm_state, KVM_CAP_PCI_SEGMENT) &&
dev->host.domain) { dev->host.domain) {
error_report("Can't assign device inside non-zero PCI segment " error_setg(errp, "Can't assign device inside non-zero PCI segment "
"as this KVM module doesn't support it."); "as this KVM module doesn't support it.");
return -ENODEV; return;
} }
if (!kvm_check_extension(kvm_state, KVM_CAP_IOMMU)) { if (!kvm_check_extension(kvm_state, KVM_CAP_IOMMU)) {
error_report("No IOMMU found. Unable to assign device \"%s\"", error_setg(errp, "No IOMMU found. Unable to assign device \"%s\"",
dev->dev.qdev.id); dev->dev.qdev.id);
return -ENODEV; return;
} }
if (dev->features & ASSIGNED_DEVICE_SHARE_INTX_MASK && if (dev->features & ASSIGNED_DEVICE_SHARE_INTX_MASK &&
@@ -805,36 +821,39 @@ static int assign_device(AssignedDevice *dev)
r = kvm_device_pci_assign(kvm_state, &dev->host, flags, &dev->dev_id); r = kvm_device_pci_assign(kvm_state, &dev->host, flags, &dev->dev_id);
if (r < 0) { if (r < 0) {
error_report("Failed to assign device \"%s\" : %s",
dev->dev.qdev.id, strerror(-r));
switch (r) { switch (r) {
case -EBUSY: case -EBUSY: {
assign_failed_examine(dev); char *cause;
cause = assign_failed_examine(dev);
error_setg_errno(errp, -r, "Failed to assign device \"%s\"\n%s",
dev->dev.qdev.id, cause);
g_free(cause);
break; break;
}
default: default:
error_setg_errno(errp, -r, "Failed to assign device \"%s\"",
dev->dev.qdev.id);
break; break;
} }
} }
return r;
} }
static bool check_irqchip_in_kernel(void) static void verify_irqchip_in_kernel(Error **errp)
{ {
if (kvm_irqchip_in_kernel()) { if (kvm_irqchip_in_kernel()) {
return true; return;
} }
error_report("pci-assign: error: requires KVM with in-kernel irqchip " error_setg(errp, "pci-assign requires KVM with in-kernel irqchip enabled");
"enabled");
return false;
} }
static int assign_intx(AssignedDevice *dev) static int assign_intx(AssignedDevice *dev, Error **errp)
{ {
AssignedIRQType new_type; AssignedIRQType new_type;
PCIINTxRoute intx_route; PCIINTxRoute intx_route;
bool intx_host_msi; bool intx_host_msi;
int r; int r;
Error *local_err = NULL;
/* Interrupt PIN 0 means don't use INTx */ /* Interrupt PIN 0 means don't use INTx */
if (assigned_dev_pci_read_byte(&dev->dev, PCI_INTERRUPT_PIN) == 0) { if (assigned_dev_pci_read_byte(&dev->dev, PCI_INTERRUPT_PIN) == 0) {
@@ -842,7 +861,9 @@ static int assign_intx(AssignedDevice *dev)
return 0; return 0;
} }
if (!check_irqchip_in_kernel()) { verify_irqchip_in_kernel(&local_err);
if (local_err) {
error_propagate(errp, local_err);
return -ENOTSUP; return -ENOTSUP;
} }
@@ -905,10 +926,11 @@ retry:
dev->features |= ASSIGNED_DEVICE_PREFER_MSI_MASK; dev->features |= ASSIGNED_DEVICE_PREFER_MSI_MASK;
goto retry; goto retry;
} }
error_report("Failed to assign irq for \"%s\": %s", error_setg_errno(errp, -r,
dev->dev.qdev.id, strerror(-r)); "Failed to assign irq for \"%s\"\n"
error_report("Perhaps you are assigning a device " "Perhaps you are assigning a device "
"that shares an IRQ with another device?"); "that shares an IRQ with another device?",
dev->dev.qdev.id);
return r; return r;
} }
@@ -934,8 +956,11 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev)
Error *err = NULL; Error *err = NULL;
int r; int r;
r = assign_intx(assigned_dev); r = assign_intx(assigned_dev, &err);
if (r < 0) { if (r < 0) {
error_report("%s", error_get_pretty(err));
error_free(err);
err = NULL;
qdev_unplug(&dev->qdev, &err); qdev_unplug(&dev->qdev, &err);
assert(!err); assert(!err);
} }
@@ -986,7 +1011,13 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev)
assigned_dev->intx_route.irq = -1; assigned_dev->intx_route.irq = -1;
assigned_dev->assigned_irq_type = ASSIGNED_IRQ_MSI; assigned_dev->assigned_irq_type = ASSIGNED_IRQ_MSI;
} else { } else {
assign_intx(assigned_dev); Error *local_err = NULL;
assign_intx(assigned_dev, &local_err);
if (local_err) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
}
} }
} }
@@ -1128,7 +1159,13 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev)
assigned_dev->intx_route.irq = -1; assigned_dev->intx_route.irq = -1;
assigned_dev->assigned_irq_type = ASSIGNED_IRQ_MSIX; assigned_dev->assigned_irq_type = ASSIGNED_IRQ_MSIX;
} else { } else {
assign_intx(assigned_dev); Error *local_err = NULL;
assign_intx(assigned_dev, &local_err);
if (local_err) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
}
} }
} }
@@ -1214,11 +1251,12 @@ static void assigned_dev_setup_cap_read(AssignedDevice *dev, uint32_t offset,
assigned_dev_emulate_config_read(dev, offset + PCI_CAP_LIST_NEXT, 1); assigned_dev_emulate_config_read(dev, offset + PCI_CAP_LIST_NEXT, 1);
} }
static int assigned_device_pci_cap_init(PCIDevice *pci_dev) static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
{ {
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
PCIRegion *pci_region = dev->real_device.regions; PCIRegion *pci_region = dev->real_device.regions;
int ret, pos; int ret, pos;
Error *local_err = NULL;
/* Clear initial capabilities pointer and status copied from hw */ /* Clear initial capabilities pointer and status copied from hw */
pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0); pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0);
@@ -1230,13 +1268,17 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
* MSI capability is the 1st capability in capability config */ * MSI capability is the 1st capability in capability config */
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0); pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) { if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
if (!check_irqchip_in_kernel()) { verify_irqchip_in_kernel(&local_err);
if (local_err) {
error_propagate(errp, local_err);
return -ENOTSUP; return -ENOTSUP;
} }
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
/* Only 32-bit/no-mask currently supported */ /* Only 32-bit/no-mask currently supported */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSI, pos, 10,
&local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
pci_dev->msi_cap = pos; pci_dev->msi_cap = pos;
@@ -1259,12 +1301,16 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
int bar_nr; int bar_nr;
uint32_t msix_table_entry; uint32_t msix_table_entry;
if (!check_irqchip_in_kernel()) { verify_irqchip_in_kernel(&local_err);
if (local_err) {
error_propagate(errp, local_err);
return -ENOTSUP; return -ENOTSUP;
} }
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSIX, pos, 12,
&local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
pci_dev->msix_cap = pos; pci_dev->msix_cap = pos;
@@ -1291,8 +1337,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
if (pos) { if (pos) {
uint16_t pmc; uint16_t pmc;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF,
&local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@@ -1330,8 +1378,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
*/ */
size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos); size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos);
if (size < 0x34) { if (size < 0x34) {
error_report("%s: Invalid size PCIe cap-id 0x%x", error_setg(errp, "Invalid size PCIe cap-id 0x%x",
__func__, PCI_CAP_ID_EXP); PCI_CAP_ID_EXP);
return -EINVAL; return -EINVAL;
} else if (size != 0x3c) { } else if (size != 0x3c) {
error_report("WARNING, %s: PCIe cap-id 0x%x has " error_report("WARNING, %s: PCIe cap-id 0x%x has "
@@ -1352,13 +1400,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
} }
if (size == 0) { if (size == 0) {
error_report("%s: Unsupported PCI express capability version %d", error_setg(errp, "Unsupported PCI express capability version %d",
__func__, version); version);
return -EINVAL; return -EINVAL;
} }
ret = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, pos, size); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_EXP, pos, size,
&local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@@ -1368,8 +1418,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
type = (type & PCI_EXP_FLAGS_TYPE) >> 4; type = (type & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT && if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) { type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {
error_report("Device assignment only supports endpoint assignment," error_setg(errp, "Device assignment only supports endpoint "
" device type %d", type); "assignment, device type %d", type);
return -EINVAL; return -EINVAL;
} }
@@ -1431,8 +1481,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
uint32_t status; uint32_t status;
/* Only expose the minimum, 8 byte capability */ /* Only expose the minimum, 8 byte capability */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PCIX, pos, 8); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PCIX, pos, 8,
&local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@@ -1457,8 +1509,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0); pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0);
if (pos) { if (pos) {
/* Direct R/W passthrough */ /* Direct R/W passthrough */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VPD, pos, 8,
&local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@@ -1473,8 +1527,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
pos += PCI_CAP_LIST_NEXT) { pos += PCI_CAP_LIST_NEXT) {
uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS); uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS);
/* Direct R/W passthrough */ /* Direct R/W passthrough */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VNDR, pos, len); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VNDR, pos, len,
&local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@@ -1602,20 +1658,19 @@ static void assigned_dev_msix_reset(AssignedDevice *dev)
} }
} }
static int assigned_dev_register_msix_mmio(AssignedDevice *dev) static void assigned_dev_register_msix_mmio(AssignedDevice *dev, Error **errp)
{ {
dev->msix_table = mmap(NULL, MSIX_PAGE_SIZE, PROT_READ|PROT_WRITE, dev->msix_table = mmap(NULL, MSIX_PAGE_SIZE, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, 0, 0); MAP_ANONYMOUS|MAP_PRIVATE, 0, 0);
if (dev->msix_table == MAP_FAILED) { if (dev->msix_table == MAP_FAILED) {
error_report("fail allocate msix_table! %s", strerror(errno)); error_setg_errno(errp, errno, "failed to allocate msix_table");
return -EFAULT; return;
} }
assigned_dev_msix_reset(dev); assigned_dev_msix_reset(dev);
memory_region_init_io(&dev->mmio, OBJECT(dev), &assigned_dev_msix_mmio_ops, memory_region_init_io(&dev->mmio, OBJECT(dev), &assigned_dev_msix_mmio_ops,
dev, "assigned-dev-msix", MSIX_PAGE_SIZE); dev, "assigned-dev-msix", MSIX_PAGE_SIZE);
return 0;
} }
static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev) static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
@@ -1698,16 +1753,17 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
uint8_t e_intx; uint8_t e_intx;
int r; int r;
Error *local_err = NULL;
if (!kvm_enabled()) { if (!kvm_enabled()) {
error_report("pci-assign: error: requires KVM support"); error_setg(&local_err, "pci-assign requires KVM support");
return -1; goto exit_with_error;
} }
if (!dev->host.domain && !dev->host.bus && !dev->host.slot && if (!dev->host.domain && !dev->host.bus && !dev->host.slot &&
!dev->host.function) { !dev->host.function) {
error_report("pci-assign: error: no host device specified"); error_setg(&local_err, "no host device specified");
return -1; goto exit_with_error;
} }
/* /*
@@ -1730,27 +1786,28 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
memcpy(dev->emulate_config_write, dev->emulate_config_read, memcpy(dev->emulate_config_write, dev->emulate_config_read,
sizeof(dev->emulate_config_read)); sizeof(dev->emulate_config_read));
if (get_real_device(dev)) { get_real_device(dev, &local_err);
error_report("pci-assign: Error: Couldn't get real device (%s)!", if (local_err) {
dev->dev.qdev.id);
goto out; goto out;
} }
if (assigned_device_pci_cap_init(pci_dev) < 0) { if (assigned_device_pci_cap_init(pci_dev, &local_err) < 0) {
goto out; goto out;
} }
/* intercept MSI-X entry page in the MMIO */ /* intercept MSI-X entry page in the MMIO */
if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) { if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) {
if (assigned_dev_register_msix_mmio(dev)) { assigned_dev_register_msix_mmio(dev, &local_err);
if (local_err) {
goto out; goto out;
} }
} }
/* handle real device's MMIO/PIO BARs */ /* handle real device's MMIO/PIO BARs */
if (assigned_dev_register_regions(dev->real_device.regions, assigned_dev_register_regions(dev->real_device.regions,
dev->real_device.region_number, dev->real_device.region_number, dev,
dev)) { &local_err);
if (local_err) {
goto out; goto out;
} }
@@ -1761,13 +1818,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
dev->intx_route.irq = -1; dev->intx_route.irq = -1;
/* assign device to guest */ /* assign device to guest */
r = assign_device(dev); assign_device(dev, &local_err);
if (r < 0) { if (local_err) {
goto out; goto out;
} }
/* assign legacy INTx to the device */ /* assign legacy INTx to the device */
r = assign_intx(dev); r = assign_intx(dev, &local_err);
if (r < 0) { if (r < 0) {
goto assigned_out; goto assigned_out;
} }
@@ -1780,8 +1837,14 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
assigned_out: assigned_out:
deassign_device(dev); deassign_device(dev);
out: out:
free_assigned_device(dev); free_assigned_device(dev);
exit_with_error:
assert(local_err);
qerror_report_err(local_err);
error_free(local_err);
return -1; return -1;
} }

View File

@@ -124,14 +124,14 @@ static const TPRInstruction tpr_instr[] = {
static void read_guest_rom_state(VAPICROMState *s) static void read_guest_rom_state(VAPICROMState *s)
{ {
cpu_physical_memory_rw(s->rom_state_paddr, (void *)&s->rom_state, cpu_physical_memory_read(s->rom_state_paddr, &s->rom_state,
sizeof(GuestROMState), 0); sizeof(GuestROMState));
} }
static void write_guest_rom_state(VAPICROMState *s) static void write_guest_rom_state(VAPICROMState *s)
{ {
cpu_physical_memory_rw(s->rom_state_paddr, (void *)&s->rom_state, cpu_physical_memory_write(s->rom_state_paddr, &s->rom_state,
sizeof(GuestROMState), 1); sizeof(GuestROMState));
} }
static void update_guest_rom_state(VAPICROMState *s) static void update_guest_rom_state(VAPICROMState *s)
@@ -311,16 +311,14 @@ static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong i
for (pos = le32_to_cpu(s->rom_state.fixup_start); for (pos = le32_to_cpu(s->rom_state.fixup_start);
pos < le32_to_cpu(s->rom_state.fixup_end); pos < le32_to_cpu(s->rom_state.fixup_end);
pos += 4) { pos += 4) {
cpu_physical_memory_rw(paddr + pos - s->rom_state.vaddr, cpu_physical_memory_read(paddr + pos - s->rom_state.vaddr,
(void *)&offset, sizeof(offset), 0); &offset, sizeof(offset));
offset = le32_to_cpu(offset); offset = le32_to_cpu(offset);
cpu_physical_memory_rw(paddr + offset, (void *)&patch, cpu_physical_memory_read(paddr + offset, &patch, sizeof(patch));
sizeof(patch), 0);
patch = le32_to_cpu(patch); patch = le32_to_cpu(patch);
patch += rom_state_vaddr - le32_to_cpu(s->rom_state.vaddr); patch += rom_state_vaddr - le32_to_cpu(s->rom_state.vaddr);
patch = cpu_to_le32(patch); patch = cpu_to_le32(patch);
cpu_physical_memory_rw(paddr + offset, (void *)&patch, cpu_physical_memory_write(paddr + offset, &patch, sizeof(patch));
sizeof(patch), 1);
} }
read_guest_rom_state(s); read_guest_rom_state(s);
s->vapic_paddr = paddr + le32_to_cpu(s->rom_state.vapic_vaddr) - s->vapic_paddr = paddr + le32_to_cpu(s->rom_state.vapic_vaddr) -
@@ -364,8 +362,8 @@ static int vapic_enable(VAPICROMState *s, X86CPU *cpu)
} }
vapic_paddr = s->vapic_paddr + vapic_paddr = s->vapic_paddr +
(((hwaddr)cpu_number) << VAPIC_CPU_SHIFT); (((hwaddr)cpu_number) << VAPIC_CPU_SHIFT);
cpu_physical_memory_rw(vapic_paddr + offsetof(VAPICState, enabled), cpu_physical_memory_write(vapic_paddr + offsetof(VAPICState, enabled),
(void *)&enabled, sizeof(enabled), 1); &enabled, sizeof(enabled));
apic_enable_vapic(cpu->apic_state, vapic_paddr); apic_enable_vapic(cpu->apic_state, vapic_paddr);
s->state = VAPIC_ACTIVE; s->state = VAPIC_ACTIVE;
@@ -535,7 +533,7 @@ static int patch_hypercalls(VAPICROMState *s)
uint8_t *rom; uint8_t *rom;
rom = g_malloc(s->rom_size); rom = g_malloc(s->rom_size);
cpu_physical_memory_rw(rom_paddr, rom, s->rom_size, 0); cpu_physical_memory_read(rom_paddr, rom, s->rom_size);
for (pos = 0; pos < s->rom_size - sizeof(vmcall_pattern); pos++) { for (pos = 0; pos < s->rom_size - sizeof(vmcall_pattern); pos++) {
if (kvm_irqchip_in_kernel()) { if (kvm_irqchip_in_kernel()) {
@@ -551,8 +549,7 @@ static int patch_hypercalls(VAPICROMState *s)
} }
if (memcmp(rom + pos, pattern, 7) == 0 && if (memcmp(rom + pos, pattern, 7) == 0 &&
(rom[pos + 7] == alternates[0] || rom[pos + 7] == alternates[1])) { (rom[pos + 7] == alternates[0] || rom[pos + 7] == alternates[1])) {
cpu_physical_memory_rw(rom_paddr + pos + 5, (uint8_t *)patch, cpu_physical_memory_write(rom_paddr + pos + 5, patch, 3);
3, 1);
/* /*
* Don't flush the tb here. Under ordinary conditions, the patched * Don't flush the tb here. Under ordinary conditions, the patched
* calls are miles away from the current IP. Under malicious * calls are miles away from the current IP. Under malicious
@@ -760,8 +757,8 @@ static int vapic_post_load(void *opaque, int version_id)
run_on_cpu(first_cpu, do_vapic_enable, s); run_on_cpu(first_cpu, do_vapic_enable, s);
} else { } else {
zero = g_malloc0(s->rom_state.vapic_size); zero = g_malloc0(s->rom_state.vapic_size);
cpu_physical_memory_rw(s->vapic_paddr, zero, cpu_physical_memory_write(s->vapic_paddr, zero,
s->rom_state.vapic_size, 1); s->rom_state.vapic_size);
g_free(zero); g_free(zero);
} }
} }

View File

@@ -612,6 +612,21 @@ int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
return e820_entries; return e820_entries;
} }
int e820_get_num_entries(void)
{
return e820_entries;
}
bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length)
{
if (idx < e820_entries && e820_table[idx].type == cpu_to_le32(type)) {
*address = le64_to_cpu(e820_table[idx].address);
*length = le64_to_cpu(e820_table[idx].length);
return true;
}
return false;
}
/* Calculates the limit to CPU APIC ID values /* Calculates the limit to CPU APIC ID values
* *
* This function returns the limit for the APIC ID value, so that all * This function returns the limit for the APIC ID value, so that all
@@ -627,8 +642,8 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)
static FWCfgState *bochs_bios_init(void) static FWCfgState *bochs_bios_init(void)
{ {
FWCfgState *fw_cfg; FWCfgState *fw_cfg;
uint8_t *smbios_table; uint8_t *smbios_tables, *smbios_anchor;
size_t smbios_len; size_t smbios_tables_len, smbios_anchor_len;
uint64_t *numa_fw_cfg; uint64_t *numa_fw_cfg;
int i, j; int i, j;
unsigned int apic_id_limit = pc_apic_id_limit(max_cpus); unsigned int apic_id_limit = pc_apic_id_limit(max_cpus);
@@ -655,10 +670,21 @@ static FWCfgState *bochs_bios_init(void)
acpi_tables, acpi_tables_len); acpi_tables, acpi_tables_len);
fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override()); fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
smbios_table = smbios_get_table(&smbios_len); smbios_tables = smbios_get_table_legacy(&smbios_tables_len);
if (smbios_table) if (smbios_tables) {
fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
smbios_table, smbios_len); smbios_tables, smbios_tables_len);
}
smbios_get_tables(&smbios_tables, &smbios_tables_len,
&smbios_anchor, &smbios_anchor_len);
if (smbios_anchor) {
fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-tables",
smbios_tables, smbios_tables_len);
fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-anchor",
smbios_anchor, smbios_anchor_len);
}
fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
&e820_reserve, sizeof(e820_reserve)); &e820_reserve, sizeof(e820_reserve));
fw_cfg_add_file(fw_cfg, "etc/e820", e820_table, fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
@@ -1027,6 +1053,9 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(icc_bridge), 0, sysbus_mmio_map_overlap(SYS_BUS_DEVICE(icc_bridge), 0,
APIC_DEFAULT_ADDRESS, 0x1000); APIC_DEFAULT_ADDRESS, 0x1000);
} }
/* tell smbios about cpuid version and features */
smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]);
} }
/* pci-info ROM file. Little endian format */ /* pci-info ROM file. Little endian format */

View File

@@ -60,7 +60,8 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
static bool has_pci_info; static bool has_pci_info;
static bool has_acpi_build = true; static bool has_acpi_build = true;
static bool smbios_type1_defaults = true; static bool smbios_defaults = true;
static bool smbios_legacy_mode;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host. * pages in the host.
@@ -143,10 +144,10 @@ static void pc_init1(QEMUMachineInitArgs *args,
guest_info->has_pci_info = has_pci_info; guest_info->has_pci_info = has_pci_info;
guest_info->isapc_ram_fw = !pci_enabled; guest_info->isapc_ram_fw = !pci_enabled;
if (smbios_type1_defaults) { if (smbios_defaults) {
/* These values are guest ABI, do not change */ /* These values are guest ABI, do not change */
smbios_set_type1_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
args->machine->name); args->machine->name, smbios_legacy_mode);
} }
/* allocate ram and load rom/bios */ /* allocate ram and load rom/bios */
@@ -262,9 +263,15 @@ static void pc_init_pci(QEMUMachineInitArgs *args)
pc_init1(args, 1, 1); pc_init1(args, 1, 1);
} }
static void pc_compat_2_0(QEMUMachineInitArgs *args)
{
smbios_legacy_mode = true;
}
static void pc_compat_1_7(QEMUMachineInitArgs *args) static void pc_compat_1_7(QEMUMachineInitArgs *args)
{ {
smbios_type1_defaults = false; pc_compat_2_0(args);
smbios_defaults = false;
gigabyte_align = false; gigabyte_align = false;
option_rom_has_mr = true; option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC); x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
@@ -303,6 +310,12 @@ static void pc_compat_1_2(QEMUMachineInitArgs *args)
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
} }
static void pc_init_pci_2_0(QEMUMachineInitArgs *args)
{
pc_compat_2_0(args);
pc_init_pci(args);
}
static void pc_init_pci_1_7(QEMUMachineInitArgs *args) static void pc_init_pci_1_7(QEMUMachineInitArgs *args)
{ {
pc_compat_1_7(args); pc_compat_1_7(args);
@@ -345,7 +358,7 @@ static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args)
{ {
has_pci_info = false; has_pci_info = false;
has_acpi_build = false; has_acpi_build = false;
smbios_type1_defaults = false; smbios_defaults = false;
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode(); enable_compat_apic_id_mode();
pc_init1(args, 1, 0); pc_init1(args, 1, 0);
@@ -355,7 +368,7 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
{ {
has_pci_info = false; has_pci_info = false;
has_acpi_build = false; has_acpi_build = false;
smbios_type1_defaults = false; smbios_defaults = false;
if (!args->cpu_model) { if (!args->cpu_model) {
args->cpu_model = "486"; args->cpu_model = "486";
} }
@@ -383,16 +396,28 @@ static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
.desc = "Standard PC (i440FX + PIIX, 1996)", \ .desc = "Standard PC (i440FX + PIIX, 1996)", \
.hot_add_cpu = pc_hot_add_cpu .hot_add_cpu = pc_hot_add_cpu
#define PC_I440FX_2_0_MACHINE_OPTIONS \ #define PC_I440FX_2_1_MACHINE_OPTIONS \
PC_I440FX_MACHINE_OPTIONS, \ PC_I440FX_MACHINE_OPTIONS, \
.default_machine_opts = "firmware=bios-256k.bin" .default_machine_opts = "firmware=bios-256k.bin"
static QEMUMachine pc_i440fx_machine_v2_1 = {
PC_I440FX_2_1_MACHINE_OPTIONS,
.name = "pc-i440fx-2.1",
.alias = "pc",
.init = pc_init_pci,
.is_default = 1,
};
#define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
static QEMUMachine pc_i440fx_machine_v2_0 = { static QEMUMachine pc_i440fx_machine_v2_0 = {
PC_I440FX_2_0_MACHINE_OPTIONS, PC_I440FX_2_0_MACHINE_OPTIONS,
.name = "pc-i440fx-2.0", .name = "pc-i440fx-2.0",
.alias = "pc", .init = pc_init_pci_2_0,
.init = pc_init_pci, .compat_props = (GlobalProperty[]) {
.is_default = 1, PC_COMPAT_2_0,
{ /* end of list */ }
},
}; };
#define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
@@ -817,6 +842,7 @@ static QEMUMachine xenfv_machine = {
static void pc_machine_init(void) static void pc_machine_init(void)
{ {
qemu_register_machine(&pc_i440fx_machine_v2_1);
qemu_register_machine(&pc_i440fx_machine_v2_0); qemu_register_machine(&pc_i440fx_machine_v2_0);
qemu_register_machine(&pc_i440fx_machine_v1_7); qemu_register_machine(&pc_i440fx_machine_v1_7);
qemu_register_machine(&pc_i440fx_machine_v1_6); qemu_register_machine(&pc_i440fx_machine_v1_6);

View File

@@ -50,7 +50,8 @@
static bool has_pci_info; static bool has_pci_info;
static bool has_acpi_build = true; static bool has_acpi_build = true;
static bool smbios_type1_defaults = true; static bool smbios_defaults = true;
static bool smbios_legacy_mode;
/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
* host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
* pages in the host. * pages in the host.
@@ -130,10 +131,10 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
guest_info->isapc_ram_fw = false; guest_info->isapc_ram_fw = false;
guest_info->has_acpi_build = has_acpi_build; guest_info->has_acpi_build = has_acpi_build;
if (smbios_type1_defaults) { if (smbios_defaults) {
/* These values are guest ABI, do not change */ /* These values are guest ABI, do not change */
smbios_set_type1_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)", smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)",
args->machine->name); args->machine->name, smbios_legacy_mode);
} }
/* allocate ram and load rom/bios */ /* allocate ram and load rom/bios */
@@ -240,9 +241,15 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
} }
} }
static void pc_compat_2_0(QEMUMachineInitArgs *args)
{
smbios_legacy_mode = true;
}
static void pc_compat_1_7(QEMUMachineInitArgs *args) static void pc_compat_1_7(QEMUMachineInitArgs *args)
{ {
smbios_type1_defaults = false; pc_compat_2_0(args);
smbios_defaults = false;
gigabyte_align = false; gigabyte_align = false;
option_rom_has_mr = true; option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC); x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
@@ -268,6 +275,12 @@ static void pc_compat_1_4(QEMUMachineInitArgs *args)
x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
} }
static void pc_q35_init_2_0(QEMUMachineInitArgs *args)
{
pc_compat_2_0(args);
pc_q35_init(args);
}
static void pc_q35_init_1_7(QEMUMachineInitArgs *args) static void pc_q35_init_1_7(QEMUMachineInitArgs *args)
{ {
pc_compat_1_7(args); pc_compat_1_7(args);
@@ -297,15 +310,27 @@ static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
.desc = "Standard PC (Q35 + ICH9, 2009)", \ .desc = "Standard PC (Q35 + ICH9, 2009)", \
.hot_add_cpu = pc_hot_add_cpu .hot_add_cpu = pc_hot_add_cpu
#define PC_Q35_2_0_MACHINE_OPTIONS \ #define PC_Q35_2_1_MACHINE_OPTIONS \
PC_Q35_MACHINE_OPTIONS, \ PC_Q35_MACHINE_OPTIONS, \
.default_machine_opts = "firmware=bios-256k.bin" .default_machine_opts = "firmware=bios-256k.bin"
static QEMUMachine pc_q35_machine_v2_1 = {
PC_Q35_2_1_MACHINE_OPTIONS,
.name = "pc-q35-2.1",
.alias = "q35",
.init = pc_q35_init,
};
#define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
static QEMUMachine pc_q35_machine_v2_0 = { static QEMUMachine pc_q35_machine_v2_0 = {
PC_Q35_2_0_MACHINE_OPTIONS, PC_Q35_2_0_MACHINE_OPTIONS,
.name = "pc-q35-2.0", .name = "pc-q35-2.0",
.alias = "q35", .init = pc_q35_init_2_0,
.init = pc_q35_init, .compat_props = (GlobalProperty[]) {
PC_Q35_COMPAT_2_0,
{ /* end of list */ }
},
}; };
#define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS #define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
@@ -358,6 +383,7 @@ static QEMUMachine pc_q35_machine_v1_4 = {
static void pc_q35_machine_init(void) static void pc_q35_machine_init(void)
{ {
qemu_register_machine(&pc_q35_machine_v2_1);
qemu_register_machine(&pc_q35_machine_v2_0); qemu_register_machine(&pc_q35_machine_v2_0);
qemu_register_machine(&pc_q35_machine_v1_7); qemu_register_machine(&pc_q35_machine_v1_7);
qemu_register_machine(&pc_q35_machine_v1_6); qemu_register_machine(&pc_q35_machine_v1_6);

View File

@@ -18,12 +18,13 @@
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "sysemu/cpus.h"
#include "hw/i386/pc.h"
#include "hw/i386/smbios.h" #include "hw/i386/smbios.h"
#include "hw/loader.h" #include "hw/loader.h"
/*
* Structures shared with the BIOS /* legacy structures and constants for <= 2.0 machines */
*/
struct smbios_header { struct smbios_header {
uint16_t length; uint16_t length;
uint8_t type; uint8_t type;
@@ -46,14 +47,23 @@ struct smbios_table {
static uint8_t *smbios_entries; static uint8_t *smbios_entries;
static size_t smbios_entries_len; static size_t smbios_entries_len;
static bool smbios_legacy = true;
/* end: legacy structures & constants for <= 2.0 machines */
static uint8_t *smbios_tables;
static size_t smbios_tables_len;
static unsigned smbios_table_max;
static unsigned smbios_table_cnt;
static struct smbios_entry_point ep;
static int smbios_type4_count = 0; static int smbios_type4_count = 0;
static bool smbios_immutable; static bool smbios_immutable;
static bool smbios_have_defaults;
static uint32_t smbios_cpuid_version, smbios_cpuid_features, smbios_smp_sockets;
static struct { static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
bool seen; static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
int headertype;
Location loc;
} first_opt[2];
static struct { static struct {
const char *vendor, *version, *date; const char *vendor, *version, *date;
@@ -66,6 +76,22 @@ static struct {
/* uuid is in qemu_uuid[] */ /* uuid is in qemu_uuid[] */
} type1; } type1;
static struct {
const char *manufacturer, *product, *version, *serial, *asset, *location;
} type2;
static struct {
const char *manufacturer, *version, *serial, *asset, *sku;
} type3;
static struct {
const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
} type4;
static struct {
const char *loc_pfx, *bank, *manufacturer, *serial, *asset, *part;
} type17;
static QemuOptsList qemu_smbios_opts = { static QemuOptsList qemu_smbios_opts = {
.name = "smbios", .name = "smbios",
.head = QTAILQ_HEAD_INITIALIZER(qemu_smbios_opts.head), .head = QTAILQ_HEAD_INITIALIZER(qemu_smbios_opts.head),
@@ -149,6 +175,134 @@ static const QemuOptDesc qemu_smbios_type1_opts[] = {
{ /* end of list */ } { /* end of list */ }
}; };
static const QemuOptDesc qemu_smbios_type2_opts[] = {
{
.name = "type",
.type = QEMU_OPT_NUMBER,
.help = "SMBIOS element type",
},{
.name = "manufacturer",
.type = QEMU_OPT_STRING,
.help = "manufacturer name",
},{
.name = "product",
.type = QEMU_OPT_STRING,
.help = "product name",
},{
.name = "version",
.type = QEMU_OPT_STRING,
.help = "version number",
},{
.name = "serial",
.type = QEMU_OPT_STRING,
.help = "serial number",
},{
.name = "asset",
.type = QEMU_OPT_STRING,
.help = "asset tag number",
},{
.name = "location",
.type = QEMU_OPT_STRING,
.help = "location in chassis",
},
{ /* end of list */ }
};
static const QemuOptDesc qemu_smbios_type3_opts[] = {
{
.name = "type",
.type = QEMU_OPT_NUMBER,
.help = "SMBIOS element type",
},{
.name = "manufacturer",
.type = QEMU_OPT_STRING,
.help = "manufacturer name",
},{
.name = "version",
.type = QEMU_OPT_STRING,
.help = "version number",
},{
.name = "serial",
.type = QEMU_OPT_STRING,
.help = "serial number",
},{
.name = "asset",
.type = QEMU_OPT_STRING,
.help = "asset tag number",
},{
.name = "sku",
.type = QEMU_OPT_STRING,
.help = "SKU number",
},
{ /* end of list */ }
};
static const QemuOptDesc qemu_smbios_type4_opts[] = {
{
.name = "type",
.type = QEMU_OPT_NUMBER,
.help = "SMBIOS element type",
},{
.name = "sock_pfx",
.type = QEMU_OPT_STRING,
.help = "socket designation string prefix",
},{
.name = "manufacturer",
.type = QEMU_OPT_STRING,
.help = "manufacturer name",
},{
.name = "version",
.type = QEMU_OPT_STRING,
.help = "version number",
},{
.name = "serial",
.type = QEMU_OPT_STRING,
.help = "serial number",
},{
.name = "asset",
.type = QEMU_OPT_STRING,
.help = "asset tag number",
},{
.name = "part",
.type = QEMU_OPT_STRING,
.help = "part number",
},
{ /* end of list */ }
};
static const QemuOptDesc qemu_smbios_type17_opts[] = {
{
.name = "type",
.type = QEMU_OPT_NUMBER,
.help = "SMBIOS element type",
},{
.name = "loc_pfx",
.type = QEMU_OPT_STRING,
.help = "device locator string prefix",
},{
.name = "bank",
.type = QEMU_OPT_STRING,
.help = "bank locator string",
},{
.name = "manufacturer",
.type = QEMU_OPT_STRING,
.help = "manufacturer name",
},{
.name = "serial",
.type = QEMU_OPT_STRING,
.help = "serial number",
},{
.name = "asset",
.type = QEMU_OPT_STRING,
.help = "asset tag number",
},{
.name = "part",
.type = QEMU_OPT_STRING,
.help = "part number",
},
{ /* end of list */ }
};
static void smbios_register_config(void) static void smbios_register_config(void)
{ {
qemu_add_opts(&qemu_smbios_opts); qemu_add_opts(&qemu_smbios_opts);
@@ -158,35 +312,17 @@ machine_init(smbios_register_config);
static void smbios_validate_table(void) static void smbios_validate_table(void)
{ {
if (smbios_type4_count && smbios_type4_count != smp_cpus) { uint32_t expect_t4_count = smbios_legacy ? smp_cpus : smbios_smp_sockets;
error_report("Number of SMBIOS Type 4 tables must match cpu count");
if (smbios_type4_count && smbios_type4_count != expect_t4_count) {
error_report("Expected %d SMBIOS Type 4 tables, got %d instead",
expect_t4_count, smbios_type4_count);
exit(1); exit(1);
} }
} }
/*
* To avoid unresolvable overlaps in data, don't allow both
* tables and fields for the same smbios type.
*/
static void smbios_check_collision(int type, int entry)
{
if (type < ARRAY_SIZE(first_opt)) {
if (first_opt[type].seen) {
if (first_opt[type].headertype != entry) {
error_report("Can't mix file= and type= for same type");
loc_push_restore(&first_opt[type].loc);
error_report("This is the conflicting setting");
loc_pop(&first_opt[type].loc);
exit(1);
}
} else {
first_opt[type].seen = true;
first_opt[type].headertype = entry;
loc_save(&first_opt[type].loc);
}
}
}
/* legacy setup functions for <= 2.0 machines */
static void smbios_add_field(int type, int offset, const void *data, size_t len) static void smbios_add_field(int type, int offset, const void *data, size_t len)
{ {
struct smbios_field *field; struct smbios_field *field;
@@ -256,22 +392,13 @@ static void smbios_build_type_1_fields(void)
} }
} }
void smbios_set_type1_defaults(const char *manufacturer, uint8_t *smbios_get_table_legacy(size_t *length)
const char *product, const char *version)
{ {
if (!type1.manufacturer) { if (!smbios_legacy) {
type1.manufacturer = manufacturer; *length = 0;
return NULL;
} }
if (!type1.product) {
type1.product = product;
}
if (!type1.version) {
type1.version = version;
}
}
uint8_t *smbios_get_table(size_t *length)
{
if (!smbios_immutable) { if (!smbios_immutable) {
smbios_build_type_0_fields(); smbios_build_type_0_fields();
smbios_build_type_1_fields(); smbios_build_type_1_fields();
@@ -281,6 +408,458 @@ uint8_t *smbios_get_table(size_t *length)
*length = smbios_entries_len; *length = smbios_entries_len;
return smbios_entries; return smbios_entries;
} }
/* end: legacy setup functions for <= 2.0 machines */
static bool smbios_skip_table(uint8_t type, bool required_table)
{
if (test_bit(type, have_binfile_bitmap)) {
return true; /* user provided their own binary blob(s) */
}
if (test_bit(type, have_fields_bitmap)) {
return false; /* user provided fields via command line */
}
if (smbios_have_defaults && required_table) {
return false; /* we're building tables, and this one's required */
}
return true;
}
#define SMBIOS_BUILD_TABLE_PRE(tbl_type, tbl_handle, tbl_required) \
struct smbios_type_##tbl_type *t; \
size_t t_off; /* table offset into smbios_tables */ \
int str_index = 0; \
do { \
/* should we skip building this table ? */ \
if (smbios_skip_table(tbl_type, tbl_required)) { \
return; \
} \
\
/* use offset of table t within smbios_tables */ \
/* (pointer must be updated after each realloc) */ \
t_off = smbios_tables_len; \
smbios_tables_len += sizeof(*t); \
smbios_tables = g_realloc(smbios_tables, smbios_tables_len); \
t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
\
t->header.type = tbl_type; \
t->header.length = sizeof(*t); \
t->header.handle = tbl_handle; \
} while (0)
#define SMBIOS_TABLE_SET_STR(tbl_type, field, value) \
do { \
int len = (value != NULL) ? strlen(value) + 1 : 0; \
if (len > 1) { \
smbios_tables = g_realloc(smbios_tables, \
smbios_tables_len + len); \
memcpy(smbios_tables + smbios_tables_len, value, len); \
smbios_tables_len += len; \
/* update pointer post-realloc */ \
t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
t->field = ++str_index; \
} else { \
t->field = 0; \
} \
} while (0)
#define SMBIOS_BUILD_TABLE_POST \
do { \
size_t term_cnt, t_size; \
\
/* add '\0' terminator (add two if no strings defined) */ \
term_cnt = (str_index == 0) ? 2 : 1; \
smbios_tables = g_realloc(smbios_tables, \
smbios_tables_len + term_cnt); \
memset(smbios_tables + smbios_tables_len, 0, term_cnt); \
smbios_tables_len += term_cnt; \
\
/* update smbios max. element size */ \
t_size = smbios_tables_len - t_off; \
if (t_size > smbios_table_max) { \
smbios_table_max = t_size; \
} \
\
/* update smbios element count */ \
smbios_table_cnt++; \
} while (0)
static void smbios_build_type_0_table(void)
{
SMBIOS_BUILD_TABLE_PRE(0, 0x000, false); /* optional, leave up to BIOS */
SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor);
SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version);
t->bios_starting_address_segment = 0xE800; /* hardcoded in SeaBIOS */
SMBIOS_TABLE_SET_STR(0, bios_release_date_str, type0.date);
t->bios_rom_size = 0; /* hardcoded in SeaBIOS with FIXME comment */
/* BIOS characteristics not supported */
memset(t->bios_characteristics, 0, 8);
t->bios_characteristics[0] = 0x08;
/* Enable targeted content distribution (needed for SVVP, per SeaBIOS) */
t->bios_characteristics_extension_bytes[0] = 0;
t->bios_characteristics_extension_bytes[1] = 4;
if (type0.have_major_minor) {
t->system_bios_major_release = type0.major;
t->system_bios_minor_release = type0.minor;
} else {
t->system_bios_major_release = 0;
t->system_bios_minor_release = 0;
}
/* hardcoded in SeaBIOS */
t->embedded_controller_major_release = 0xFF;
t->embedded_controller_minor_release = 0xFF;
SMBIOS_BUILD_TABLE_POST;
}
static void smbios_build_type_1_table(void)
{
SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */
SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
SMBIOS_TABLE_SET_STR(1, version_str, type1.version);
SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);
if (qemu_uuid_set) {
memcpy(t->uuid, qemu_uuid, 16);
} else {
memset(t->uuid, 0, 16);
}
t->wake_up_type = 0x06; /* power switch */
SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);
SMBIOS_TABLE_SET_STR(1, family_str, type1.family);
SMBIOS_BUILD_TABLE_POST;
}
static void smbios_build_type_2_table(void)
{
SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */
SMBIOS_TABLE_SET_STR(2, manufacturer_str, type2.manufacturer);
SMBIOS_TABLE_SET_STR(2, product_str, type2.product);
SMBIOS_TABLE_SET_STR(2, version_str, type2.version);
SMBIOS_TABLE_SET_STR(2, serial_number_str, type2.serial);
SMBIOS_TABLE_SET_STR(2, asset_tag_number_str, type2.asset);
t->feature_flags = 0x01; /* Motherboard */
SMBIOS_TABLE_SET_STR(2, location_str, type2.location);
t->chassis_handle = 0x300; /* Type 3 (System enclosure) */
t->board_type = 0x0A; /* Motherboard */
t->contained_element_count = 0;
SMBIOS_BUILD_TABLE_POST;
}
static void smbios_build_type_3_table(void)
{
SMBIOS_BUILD_TABLE_PRE(3, 0x300, true); /* required */
SMBIOS_TABLE_SET_STR(3, manufacturer_str, type3.manufacturer);
t->type = 0x01; /* Other */
SMBIOS_TABLE_SET_STR(3, version_str, type3.version);
SMBIOS_TABLE_SET_STR(3, serial_number_str, type3.serial);
SMBIOS_TABLE_SET_STR(3, asset_tag_number_str, type3.asset);
t->boot_up_state = 0x03; /* Safe */
t->power_supply_state = 0x03; /* Safe */
t->thermal_state = 0x03; /* Safe */
t->security_status = 0x02; /* Unknown */
t->oem_defined = 0;
t->height = 0;
t->number_of_power_cords = 0;
t->contained_element_count = 0;
SMBIOS_TABLE_SET_STR(3, sku_number_str, type3.sku);
SMBIOS_BUILD_TABLE_POST;
}
static void smbios_build_type_4_table(unsigned instance)
{
char sock_str[128];
SMBIOS_BUILD_TABLE_PRE(4, 0x400 + instance, true); /* required */
snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
t->processor_type = 0x03; /* CPU */
SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
t->processor_id[0] = smbios_cpuid_version;
t->processor_id[1] = smbios_cpuid_features;
SMBIOS_TABLE_SET_STR(4, processor_version_str, type4.version);
t->voltage = 0;
t->external_clock = 0; /* Unknown */
t->max_speed = 0; /* Unknown */
t->current_speed = 0; /* Unknown */
t->status = 0x41; /* Socket populated, CPU enabled */
t->processor_upgrade = 0x01; /* Other */
t->l1_cache_handle = 0xFFFF; /* N/A */
t->l2_cache_handle = 0xFFFF; /* N/A */
t->l3_cache_handle = 0xFFFF; /* N/A */
SMBIOS_TABLE_SET_STR(4, serial_number_str, type4.serial);
SMBIOS_TABLE_SET_STR(4, asset_tag_number_str, type4.asset);
SMBIOS_TABLE_SET_STR(4, part_number_str, type4.part);
t->core_count = t->core_enabled = smp_cores;
t->thread_count = smp_threads;
t->processor_characteristics = 0x02; /* Unknown */
t->processor_family = t->processor_family2 = 0x01; /* Other */
SMBIOS_BUILD_TABLE_POST;
smbios_type4_count++;
}
#define ONE_KB ((ram_addr_t)1 << 10)
#define ONE_MB ((ram_addr_t)1 << 20)
#define ONE_GB ((ram_addr_t)1 << 30)
#define MAX_T16_STD_SZ 0x80000000 /* 2T in Kilobytes */
static void smbios_build_type_16_table(unsigned dimm_cnt)
{
ram_addr_t size_kb;
SMBIOS_BUILD_TABLE_PRE(16, 0x1000, true); /* required */
t->location = 0x01; /* Other */
t->use = 0x03; /* System memory */
t->error_correction = 0x06; /* Multi-bit ECC (for Microsoft, per SeaBIOS) */
size_kb = QEMU_ALIGN_UP(ram_size, ONE_KB) / ONE_KB;
if (size_kb < MAX_T16_STD_SZ) {
t->maximum_capacity = size_kb;
t->extended_maximum_capacity = 0;
} else {
t->maximum_capacity = MAX_T16_STD_SZ;
t->extended_maximum_capacity = ram_size;
}
t->memory_error_information_handle = 0xFFFE; /* Not provided */
t->number_of_memory_devices = dimm_cnt;
SMBIOS_BUILD_TABLE_POST;
}
#define MAX_T17_STD_SZ 0x7FFF /* (32G - 1M), in Megabytes */
#define MAX_T17_EXT_SZ 0x80000000 /* 2P, in Megabytes */
static void smbios_build_type_17_table(unsigned instance, ram_addr_t size)
{
char loc_str[128];
ram_addr_t size_mb;
SMBIOS_BUILD_TABLE_PRE(17, 0x1100 + instance, true); /* required */
t->physical_memory_array_handle = 0x1000; /* Type 16 (Phys. Mem. Array) */
t->memory_error_information_handle = 0xFFFE; /* Not provided */
t->total_width = 0xFFFF; /* Unknown */
t->data_width = 0xFFFF; /* Unknown */
size_mb = QEMU_ALIGN_UP(size, ONE_MB) / ONE_MB;
if (size_mb < MAX_T17_STD_SZ) {
t->size = size_mb;
t->extended_size = 0;
} else {
assert(size_mb < MAX_T17_EXT_SZ);
t->size = MAX_T17_STD_SZ;
t->extended_size = size_mb;
}
t->form_factor = 0x09; /* DIMM */
t->device_set = 0; /* Not in a set */
snprintf(loc_str, sizeof(loc_str), "%s %d", type17.loc_pfx, instance);
SMBIOS_TABLE_SET_STR(17, device_locator_str, loc_str);
SMBIOS_TABLE_SET_STR(17, bank_locator_str, type17.bank);
t->memory_type = 0x07; /* RAM */
t->type_detail = 0x02; /* Other */
t->speed = 0; /* Unknown */
SMBIOS_TABLE_SET_STR(17, manufacturer_str, type17.manufacturer);
SMBIOS_TABLE_SET_STR(17, serial_number_str, type17.serial);
SMBIOS_TABLE_SET_STR(17, asset_tag_number_str, type17.asset);
SMBIOS_TABLE_SET_STR(17, part_number_str, type17.part);
t->attributes = 0; /* Unknown */
t->configured_clock_speed = 0; /* Unknown */
t->minimum_voltage = 0; /* Unknown */
t->maximum_voltage = 0; /* Unknown */
t->configured_voltage = 0; /* Unknown */
SMBIOS_BUILD_TABLE_POST;
}
static void smbios_build_type_19_table(unsigned instance,
ram_addr_t start, ram_addr_t size)
{
ram_addr_t end, start_kb, end_kb;
SMBIOS_BUILD_TABLE_PRE(19, 0x1300 + instance, true); /* required */
end = start + size - 1;
assert(end > start);
start_kb = start / ONE_KB;
end_kb = end / ONE_KB;
if (start_kb < UINT32_MAX && end_kb < UINT32_MAX) {
t->starting_address = start_kb;
t->ending_address = end_kb;
t->extended_starting_address = t->extended_ending_address = 0;
} else {
t->starting_address = t->ending_address = UINT32_MAX;
t->extended_starting_address = start;
t->extended_ending_address = end;
}
t->memory_array_handle = 0x1000; /* Type 16 (Phys. Mem. Array) */
t->partition_width = 1; /* One device per row */
SMBIOS_BUILD_TABLE_POST;
}
static void smbios_build_type_32_table(void)
{
SMBIOS_BUILD_TABLE_PRE(32, 0x2000, true); /* required */
memset(t->reserved, 0, 6);
t->boot_status = 0; /* No errors detected */
SMBIOS_BUILD_TABLE_POST;
}
static void smbios_build_type_127_table(void)
{
SMBIOS_BUILD_TABLE_PRE(127, 0x7F00, true); /* required */
SMBIOS_BUILD_TABLE_POST;
}
void smbios_set_cpuid(uint32_t version, uint32_t features)
{
smbios_cpuid_version = version;
smbios_cpuid_features = features;
}
#define SMBIOS_SET_DEFAULT(field, value) \
if (!field) { \
field = value; \
}
#define G_FREE_UNLESS_NULL(ptr) \
if (ptr != NULL) { \
g_free(ptr); \
}
void smbios_set_defaults(const char *manufacturer, const char *product,
const char *version, bool legacy_mode)
{
smbios_have_defaults = true;
smbios_legacy = legacy_mode;
/* drop unwanted version of command-line file blob(s) */
if (smbios_legacy) {
G_FREE_UNLESS_NULL(smbios_tables);
/* in legacy mode, also complain if fields were given for types > 1 */
if (find_next_bit(have_fields_bitmap,
SMBIOS_MAX_TYPE+1, 2) < SMBIOS_MAX_TYPE+1) {
error_report("can't process fields for smbios "
"types > 1 on machine versions < 2.1!");
exit(1);
}
} else {
G_FREE_UNLESS_NULL(smbios_entries);
}
SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
SMBIOS_SET_DEFAULT(type1.product, product);
SMBIOS_SET_DEFAULT(type1.version, version);
SMBIOS_SET_DEFAULT(type2.manufacturer, manufacturer);
SMBIOS_SET_DEFAULT(type2.product, product);
SMBIOS_SET_DEFAULT(type2.version, version);
SMBIOS_SET_DEFAULT(type3.manufacturer, manufacturer);
SMBIOS_SET_DEFAULT(type3.version, version);
SMBIOS_SET_DEFAULT(type4.sock_pfx, "CPU");
SMBIOS_SET_DEFAULT(type4.manufacturer, manufacturer);
SMBIOS_SET_DEFAULT(type4.version, version);
SMBIOS_SET_DEFAULT(type17.loc_pfx, "DIMM");
SMBIOS_SET_DEFAULT(type17.manufacturer, manufacturer);
}
static void smbios_entry_point_setup(void)
{
memcpy(ep.anchor_string, "_SM_", 4);
memcpy(ep.intermediate_anchor_string, "_DMI_", 5);
ep.length = sizeof(struct smbios_entry_point);
ep.entry_point_revision = 0; /* formatted_area reserved, per spec v2.1+ */
memset(ep.formatted_area, 0, 5);
/* compliant with smbios spec v2.8 */
ep.smbios_major_version = 2;
ep.smbios_minor_version = 8;
ep.smbios_bcd_revision = 0x28;
/* set during table construction, but BIOS may override: */
ep.structure_table_length = smbios_tables_len;
ep.max_structure_size = smbios_table_max;
ep.number_of_structures = smbios_table_cnt;
/* BIOS must recalculate: */
ep.checksum = 0;
ep.intermediate_checksum = 0;
ep.structure_table_address = 0; /* where BIOS has copied smbios_tables */
}
void smbios_get_tables(uint8_t **tables, size_t *tables_len,
uint8_t **anchor, size_t *anchor_len)
{
unsigned i, dimm_cnt, instance;
if (smbios_legacy) {
*tables = *anchor = NULL;
*tables_len = *anchor_len = 0;
return;
}
if (!smbios_immutable) {
smbios_build_type_0_table();
smbios_build_type_1_table();
smbios_build_type_2_table();
smbios_build_type_3_table();
smbios_smp_sockets = smp_cpus / (smp_cores * smp_threads);
assert(smbios_smp_sockets >= 1);
for (i = 0; i < smbios_smp_sockets; i++) {
smbios_build_type_4_table(i);
}
#define MAX_DIMM_SZ (16ll * ONE_GB)
#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ : ram_size % MAX_DIMM_SZ)
dimm_cnt = QEMU_ALIGN_UP(ram_size, MAX_DIMM_SZ) / MAX_DIMM_SZ;
smbios_build_type_16_table(dimm_cnt);
for (i = 0; i < dimm_cnt; i++) {
smbios_build_type_17_table(i, GET_DIMM_SZ);
}
for (i = 0, instance = 0; i < e820_get_num_entries(); i++) {
uint64_t address, length;
if (e820_get_entry(i, E820_RAM, &address, &length)) {
smbios_build_type_19_table(instance++, address, length);
}
}
smbios_build_type_32_table();
smbios_build_type_127_table();
smbios_validate_table();
smbios_entry_point_setup();
smbios_immutable = true;
}
/* return tables blob and entry point (anchor), and their sizes */
*tables = smbios_tables;
*tables_len = smbios_tables_len;
*anchor = (uint8_t *)&ep;
*anchor_len = sizeof(struct smbios_entry_point);
}
static void save_opt(const char **dest, QemuOpts *opts, const char *name) static void save_opt(const char **dest, QemuOpts *opts, const char *name)
{ {
@@ -297,11 +876,12 @@ void smbios_entry_add(QemuOpts *opts)
const char *val; const char *val;
assert(!smbios_immutable); assert(!smbios_immutable);
val = qemu_opt_get(opts, "file"); val = qemu_opt_get(opts, "file");
if (val) { if (val) {
struct smbios_structure_header *header; struct smbios_structure_header *header;
struct smbios_table *table;
int size; int size;
struct smbios_table *table; /* legacy mode only */
qemu_opts_validate(opts, qemu_smbios_file_opts, &local_err); qemu_opts_validate(opts, qemu_smbios_file_opts, &local_err);
if (local_err) { if (local_err) {
@@ -315,31 +895,60 @@ void smbios_entry_add(QemuOpts *opts)
exit(1); exit(1);
} }
if (!smbios_entries) { /*
smbios_entries_len = sizeof(uint16_t); * NOTE: standard double '\0' terminator expected, per smbios spec.
smbios_entries = g_malloc0(smbios_entries_len); * (except in legacy mode, where the second '\0' is implicit and
} * will be inserted by the BIOS).
*/
smbios_tables = g_realloc(smbios_tables, smbios_tables_len + size);
header = (struct smbios_structure_header *)(smbios_tables +
smbios_tables_len);
smbios_entries = g_realloc(smbios_entries, smbios_entries_len + if (load_image(val, (uint8_t *)header) != size) {
sizeof(*table) + size);
table = (struct smbios_table *)(smbios_entries + smbios_entries_len);
table->header.type = SMBIOS_TABLE_ENTRY;
table->header.length = cpu_to_le16(sizeof(*table) + size);
if (load_image(val, table->data) != size) {
error_report("Failed to load SMBIOS file %s", val); error_report("Failed to load SMBIOS file %s", val);
exit(1); exit(1);
} }
header = (struct smbios_structure_header *)(table->data); if (test_bit(header->type, have_fields_bitmap)) {
smbios_check_collision(header->type, SMBIOS_TABLE_ENTRY); error_report("can't load type %d struct, fields already specified!",
header->type);
exit(1);
}
set_bit(header->type, have_binfile_bitmap);
if (header->type == 4) { if (header->type == 4) {
smbios_type4_count++; smbios_type4_count++;
} }
smbios_tables_len += size;
if (size > smbios_table_max) {
smbios_table_max = size;
}
smbios_table_cnt++;
/* add a copy of the newly loaded blob to legacy smbios_entries */
/* NOTE: This code runs before smbios_set_defaults(), so we don't
* yet know which mode (legacy vs. aggregate-table) will be
* required. We therefore add the binary blob to both legacy
* (smbios_entries) and aggregate (smbios_tables) tables, and
* delete the one we don't need from smbios_set_defaults(),
* once we know which machine version has been requested.
*/
if (!smbios_entries) {
smbios_entries_len = sizeof(uint16_t);
smbios_entries = g_malloc0(smbios_entries_len);
}
smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
size + sizeof(*table));
table = (struct smbios_table *)(smbios_entries + smbios_entries_len);
table->header.type = SMBIOS_TABLE_ENTRY;
table->header.length = cpu_to_le16(sizeof(*table) + size);
memcpy(table->data, header, size);
smbios_entries_len += sizeof(*table) + size; smbios_entries_len += sizeof(*table) + size;
(*(uint16_t *)smbios_entries) = (*(uint16_t *)smbios_entries) =
cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);
/* end: add a copy of the newly loaded blob to legacy smbios_entries */
return; return;
} }
@@ -347,7 +956,16 @@ void smbios_entry_add(QemuOpts *opts)
if (val) { if (val) {
unsigned long type = strtoul(val, NULL, 0); unsigned long type = strtoul(val, NULL, 0);
smbios_check_collision(type, SMBIOS_FIELD_ENTRY); if (type > SMBIOS_MAX_TYPE) {
error_report("out of range!");
exit(1);
}
if (test_bit(type, have_binfile_bitmap)) {
error_report("can't add fields, binary file already loaded!");
exit(1);
}
set_bit(type, have_fields_bitmap);
switch (type) { switch (type) {
case 0: case 0:
@@ -391,6 +1009,57 @@ void smbios_entry_add(QemuOpts *opts)
qemu_uuid_set = true; qemu_uuid_set = true;
} }
return; return;
case 2:
qemu_opts_validate(opts, qemu_smbios_type2_opts, &local_err);
if (local_err) {
error_report("%s", error_get_pretty(local_err));
exit(1);
}
save_opt(&type2.manufacturer, opts, "manufacturer");
save_opt(&type2.product, opts, "product");
save_opt(&type2.version, opts, "version");
save_opt(&type2.serial, opts, "serial");
save_opt(&type2.asset, opts, "asset");
save_opt(&type2.location, opts, "location");
return;
case 3:
qemu_opts_validate(opts, qemu_smbios_type3_opts, &local_err);
if (local_err) {
error_report("%s", error_get_pretty(local_err));
exit(1);
}
save_opt(&type3.manufacturer, opts, "manufacturer");
save_opt(&type3.version, opts, "version");
save_opt(&type3.serial, opts, "serial");
save_opt(&type3.asset, opts, "asset");
save_opt(&type3.sku, opts, "sku");
return;
case 4:
qemu_opts_validate(opts, qemu_smbios_type4_opts, &local_err);
if (local_err) {
error_report("%s", error_get_pretty(local_err));
exit(1);
}
save_opt(&type4.sock_pfx, opts, "sock_pfx");
save_opt(&type4.manufacturer, opts, "manufacturer");
save_opt(&type4.version, opts, "version");
save_opt(&type4.serial, opts, "serial");
save_opt(&type4.asset, opts, "asset");
save_opt(&type4.part, opts, "part");
return;
case 17:
qemu_opts_validate(opts, qemu_smbios_type17_opts, &local_err);
if (local_err) {
error_report("%s", error_get_pretty(local_err));
exit(1);
}
save_opt(&type17.loc_pfx, opts, "loc_pfx");
save_opt(&type17.bank, opts, "bank");
save_opt(&type17.manufacturer, opts, "manufacturer");
save_opt(&type17.serial, opts, "serial");
save_opt(&type17.asset, opts, "asset");
save_opt(&type17.part, opts, "part");
return;
default: default:
error_report("Don't know how to build fields for SMBIOS type %ld", error_report("Don't know how to build fields for SMBIOS type %ld",
type); type);

View File

@@ -0,0 +1 @@
obj-y += xen_platform.o xen_apic.o xen_pvdevice.o

View File

@@ -438,9 +438,9 @@ static void check_cmd(AHCIState *s, int port)
if ((pr->cmd & PORT_CMD_START) && pr->cmd_issue) { if ((pr->cmd & PORT_CMD_START) && pr->cmd_issue) {
for (slot = 0; (slot < 32) && pr->cmd_issue; slot++) { for (slot = 0; (slot < 32) && pr->cmd_issue; slot++) {
if ((pr->cmd_issue & (1 << slot)) && if ((pr->cmd_issue & (1U << slot)) &&
!handle_cmd(s, port, slot)) { !handle_cmd(s, port, slot)) {
pr->cmd_issue &= ~(1 << slot); pr->cmd_issue &= ~(1U << slot);
} }
} }
} }
@@ -1293,7 +1293,7 @@ const VMStateDescription vmstate_ahci = {
VMSTATE_UINT32(control_regs.impl, AHCIState), VMSTATE_UINT32(control_regs.impl, AHCIState),
VMSTATE_UINT32(control_regs.version, AHCIState), VMSTATE_UINT32(control_regs.version, AHCIState),
VMSTATE_UINT32(idp_index, AHCIState), VMSTATE_UINT32(idp_index, AHCIState),
VMSTATE_INT32(ports, AHCIState), VMSTATE_INT32_EQUAL(ports, AHCIState),
VMSTATE_END_OF_LIST() VMSTATE_END_OF_LIST()
}, },
}; };

Some files were not shown because too many files have changed in this diff Show More