History | View | Annotate | Download (69.6 kB)
block: Make bdrv_file_open() static
Add the bdrv_open() option BDRV_O_PROTOCOL which results in passing thecall to bdrv_file_open(). Additionally, make bdrv_file_open() static andtherefore bdrv_open() the only way to call it.
Consequently, all existing calls to bdrv_file_open() have to be adjusted...
Use error_is_set() only when necessary
error_is_set(&var) is the same as var != NULL, but it takeswhole-program analysis to figure that out. Unnecessarily hard foroptimizers, static checkers, and human readers. Dumb it down toobvious.
Gets rid of several dozen Coverity false positives....
sheepdog: fix 'qemu-img map'
It was muted in the previous commit 4bc74be9. Let's revive it since nothingprevents us to do it.
With this patch, following command will work as other formats:
$ qemu-img map sheepdog:image
Cc: qemu-devel@nongnu.orgCc: Kevin Wolf <kwolf@redhat.com>...
block: Allow reference for bdrv_file_open()
Allow specifying a reference to an existing block device (by name) forbdrv_file_open() instead of a filename and/or options.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>...
sheepdog: fix clone operation by 'qemu-img create -b'
We should pass base_inode->vdi_id to base_vdi_id of SheepdogVdiReq so that sheepcan create a clone instead a fresh volume.
This fixes following command:
qemu-create -b sheepdog:base sheepdog:clone...
Merge remote branch 'luiz/queue/qmp' into qmpq
qemu-option: Remove qemu_opts_create_nofail
This is a boiler-plate _nofail variant of qemu_opts_create. Remove anduse error_abort in call sites.
null/0 arguments needs to be added for the id and fail_if_exists fieldsin affected callsites due to argument inconsistency between the normal and...
sheepdog: fix dynamic grow for running qcow2 format
When running qcow2 over sheepdog, we might meet following problem
qemu-system-x86_64: shrinking is not supported
And cause IO errors to Guest. This is because we abuse bs->total_sectors, whichis manipulated by generic block layer and race with sheepdog code....
sheepdog: check if '-o redundancy' is passed from user
This fix a segfault (that is caused by b3af018f3) of following command:
$ qemu-img convert some_img sheepdog:some_img
Cc: qemu-devel@nongnu.orgCc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>...
sheepdog: refactor do_sd_create()
We can actually use BDRVSheepdogState *s to pass most of the parameters.
Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Liu Yuan <namei.unix@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: support user-defined redundancy option
Sheepdog support two kinds of redundancy, full replication and erasure coding.
sheepdog: implement .bdrv_get_allocated_file_size
With this patch, qemu-img info sheepdog:image will show disk size for sheepdogimages.
Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
sheepdog: check simultaneous create in resend_aioreq
After reconnection happens, all the inflight requests are moved to thefailed request list. As a result, sd_co_rw_vector() can send anothercreate request before resend_aioreq() resends a create request from...
sheepdog: cancel aio requests if possible
This patch tries to cancel aio requests in pending queue and failedqueue. When the sheepdog driver cannot cancel the requests, it waitsfor them to be completed.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
sheepdog: make add_aio_request and send_aioreq void functions
These functions no longer return errors. We can make them voidfunctions and simplify the codes.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Tested-by: Liu Yuan <namei.unix@gmail.com>...
sheepdog: try to reconnect to sheepdog after network error
This introduces a failed request queue and links all the inflightrequests to the list after network error happens. After QEMUreconnects to the sheepdog server successfully, the sheepdog blockdriver will retry all the requests in the failed queue....
sheepdog: reload inode outside of resend_aioreq
This prepares for using resend_aioreq() after reconnecting to thesheepdog server.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Tested-by: Liu Yuan <namei.unix@gmail.com>Reviewed-by: Liu Yuan <namei.unix@gmail.com>...
sheepdog: handle vdi objects in resend_aio_req
The current resend_aio_req() doesn't work when the request is againstvdi objects. This fixes the problem.
sheepdog: check return values of qemu_co_recv/send correctly
If qemu_co_recv/send doesn't return the specified length, it meansthat an error happened.
sheepdog: pass copy_policy in the request
Currently copy_policy isn't used. Recent sheepdog supports erasure coding, whichmake use of copy_policy internally, but require client explicitly passingcopy_policy from base inode to newly creately inode for snapshot related...
sheepdog: explicitly set copies as type uint8_t
'copies' is actually uint8_t since day one, but request headers and some helperfunctions parameterize it as uint32_t for unknown reasons and effectivelyreserve 24 bytes for possible future use. This patch explicitly set the correct...
block: introduce BlockDriver.bdrv_needs_filename to enable some drivers.
Some drivers will have driver specifics options but no filename.This new bool allow the block layer to treat them correctly.
The .bdrv_needs_filename is set in drivers not having .bdrv_parse_filename and...
bdrv: Use "Error" for creating images
Add an Error ** parameter to BlockDriver.bdrv_create to allow morespecific error messages.
Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Error parameter for open functions
Add an Error ** parameter to bdrv_open, bdrv_file_open and associatedfunctions to allow more specific error messages.
snapshot: distinguish id and name in snapshot delete
Snapshot creation actually already distinguish id and name since it takea structured parameter *sn, but delete can't. Later an accurate deleteis needed in qmp_transaction abort and blockdev-snapshot-delete-sync,...
bdrv: Use "Error" for opening images
Add an Error ** parameter to BlockDriver.bdrv_open andBlockDriver.bdrv_file_open to allow more specific error messages.
block: introduce bdrv_get_block_status API
For now, bdrv_get_block_status is just another name for bdrv_is_allocated.The next patches will add more flags.
This also touches all block drivers with a mostly mechanical rename. Thesole exception is cow; because it calls cow_co_is_allocated from the read...
block: return get_block_status data and flags for formats
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: make bdrv_delete() static
Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is nolonger public and should be called by bdrv_unref() if refcnt isdecreased to 0.
This is an identical change because effectively, there's no multiplereference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets...
block/sheepdog: drop have_co_req() and aio_flush_request()
.io_flush() is no longer called so drop have_co_req() andaio_flush_request().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
aio: drop io_flush argument
The .io_flush() handler no longer exists and has no users. Drop theio_flush argument to aio_set_fd_handler() and related functions.
The AioFlushEventNotifierHandler and AioFlushHandler typedefs are nolonger used and are dropped too....
sheepdog: add missing .bdrv_has_zero_init
Commit 3ac21627 changed the behaviour of bdrv_has_zero_init() to defaultto 0. In the review for Sheepdog it turned out that enabling it is safe,so that commit updated one BlockDriver definition of sheepdog to use...
block/sheepdog: Rename 'dprintf' to 'DPRINTF'
'dprintf' is the name of a POSIX standard function so we should not bestealing it for our debug macro. Rename to 'DPRINTF' (in line witha number of other source files.)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
block: Don't parse protocol from file.filename
One of the major reasons for doing something new for -blockdev andblockdev-add was that the old block layer code parses filenames insteadof just taking them literally. So we should really leave it untouched...
block: change default of .has_zero_init to 0
.has_zero_init defaults to 1 for all formats and protocols.
this is a dangerous default since this means that allnew added drivers need to manually overwrite it to 0 ifthey do not ensure that a device is zero initialized...
sheepdog: fix snapshot tag initialization
This is an old and obvious bug. We should pass snapshot_id to thetag. Or simple command like 'qemu-img snapshot -a tag sheepdog:image' will fail
Cc: qemu-devel@nongnu.orgCc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
sheepdog: support 'qemu-img snapshot -a'
Just call sd_create_branch() in the snapshot_goto to rollback the image is goodenough. With this patch, 'loadvm' process for sheepdog is modified:
Suppose we have a snapshot chain A --> B --> C, we do 'loadvm A' so as to get...
sheepdog: fix loadvm operation
Currently the 'loadvm' opertaion works as following:1. switch to the snapshot2. mark current working VDI as a snapshot3. rely on sd_create_branch to create a new working VDI based on the snapshot
This works not the same as other format as QCOW2. For e.g,...
sheepdog: use BDRV_SECTOR_SIZE
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Liu Yuan <tailai.ly@taobao.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: implement .bdrv_co_is_allocated()
sheepdog: cleanup find_vdi_name
This makes 'filename' and 'tag' constant variables, and renames'for_snapshot' to 'lock' to clear how it works.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: add SD_RES_READONLY result code
Sheepdog returns SD_RES_READONLY when qemu sends write requests to thesnapshot vdi. This adds the result code and makes sd_strerror() printits error reason.
sheepdog: add helper function to reload inode
This adds a helper function to update the current inode state with thespecified vdi object.
sheepdog: resend write requests when SD_RES_READONLY is received
When a snapshot is taken from out side of qemu (e.g. qemu-imgsnapshot), write requests to the current vdi return SD_RES_READONLY.In this case, the sheepdog block driver needs to update the current...
sheepdog: add discard/trim support for sheepdog
The 'TRIM' command from VM that is to release underlying data storage forbetter thin-provision is already supported by the Sheepdog.
This patch adds the TRIM support at QEMU part.
For older Sheepdog that doesn't support it, we return 0(success) to upper layer....
block: Remove filename parameter from .bdrv_file_open()
It is unused now in all block drivers.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
sheepdog: Use bdrv_open options instead of filename
This is only to convert the internal interface that is used for passingthe "filename" to be parsed, but converting to actual fine grainedoptions is left for another day, as it doesn't look trivial.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
block: Introduce bdrv_writev_vmstate
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
The fcntl(fd, F_SETFL, O_NONBLOCK) flag is not specific to sockets.Rename to qemu_set_nonblock() just like qemu_set_cloexec().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
block: Add options QDict to bdrv_file_open() prototypes
The new parameter is unused yet.
sheepdog: show error message for halt status
Sheepdog (neither quorum nor unsafe mode) will refuse to serve IO requests whennumber of alive nodes is less than that of copies specified by users. This willreturn 0x19 to QEMU client which currently doesn't recognize it....
sheepdog: use non-blocking fd in coroutine context
Using a blocking socket in the coroutine context reduces the chance ofswitching to other work. This patch makes the sheepdog driver use anon-blocking fd always.
sheepdog: set io_flush handler in do_co_req
If an io_flush handler is not set, qemu_aio_wait doesn't invokecallbacks.
move socket_set_nodelay to osdep.c
sheepdog: accept URIs
The URI syntax is consistent with the NBD and Gluster syntax. Thesyntax is
sheepdog[+tcp]://[host:port]/vdiname[#snapid|#tag]
sheepdog: use inet_connect to simplify connect code
This uses the form "<host>:<port>" for the representation of thesheepdog server to use inet_connect.
sheepdog: add support for connecting to unix domain socket
This patch adds support for a unix domain socket for a connectionbetween qemu and local sheepdog server. You can use the unix domainsocket with the following syntax:
$ qemu sheepdog+unix:///<vdiname>?socket=<socket path>[#snapid]...
sheepdog: pass vdi_id to sheep daemon for sd_close()
Sheep daemon needs vdi_id to identify which vdi is closed to release resourcessuch as object cache.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>...
sheepdog: clean up sd_aio_setup()
The last two parameters of sd_aio_setup() are never used, so remove them.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Liu Yuan <tailai.ly@taobao.com>...
sheepdog: multiplex the rw FD to flush cache
This will reduce sockfds connected to the sheep server to one, which simply thefuture hacks.
sheepdog: implement direct write semantics
Sheepdog supports both writeback/writethrough write but has not yet supportedDIRECTIO semantics which bypass the cache completely even if Sheepdog daemon isset up with cache enabled.
Suppose cache is enabled on Sheepdog daemon size, the new cache control is...
sheepdog: pass oid directly to send_pending_req()
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Liu Yuan <tailai.ly@taobao.com>Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: don't update inode when create_and_write fails
For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmapto avoid the scenario that the object is allocated but wasn't created at theserver side. This will result in VM's IO error on the failed object....
misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: move include files to include/block/
aio: rename AIOPool to AIOCBInfo
Now that AIOPool no longer keeps a freelist, it isn't really a "pool" anymore. Rename it to AIOCBInfo and make it const since it no longerneeds to be modified.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: use bool for boolean variables
This improves readability.
sheepdog: avoid a few buffer overruns
block: do not parse BDRV_O_CACHE_WB in block drivers
Block drivers should ignore BDRV_O_CACHE_WB in .bdrv_open flags,and in the bs->open_flags.
This patch removes the code, leaving the behaviour behind as ifBDRV_O_CACHE_WB was set.
Signed-off-by: Jeff Cody <jcody@redhat.com>...
sheepdog: fix savevm and loadvm
This patch sets data to be sent to Sheepdog correctly and fixes savevmand loadvm operations on a Sheepdog image.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: don't leak socket file descriptor upon connection failure
Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
sheepdog: always use coroutine-based network functions
This reduces some code duplication.
sheepdog: do not blindly memset all read buffers
Only buffers that map to unallocated blocks need to be zeroed.
Signed-off-by: Christoph Hellwig <hch@lst.de>Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Merge remote-tracking branch 'mjt/mjt-iov2' into staging
sheepdog: split outstanding list into inflight and pending
outstanding_list_head is used for both pending and inflight requests.This patch splits it and improves readability.
sheepdog: traverse pending_list from the first for each time
The pending list can be modified in other coroutine contextsd_co_rw_vector, so we need to traverse the list from the first againafter we send the pending request.
sheepdog: fix dprintf format strings
This fixes warnings about dprintf format in debug mode.
sheepdog: restart I/O when socket becomes ready in do_co_req()
Currently, no one reenters the yielded coroutine. This fixes it.
sheepdog: use coroutine based socket functions in coroutine context
This removes blocking network I/Os in coroutine context.
sheepdog: make sure we don't free aiocb before sending all requests
This patch increments the pending counter before sending requests, andmake sures that aiocb is not freed while sending them.
sheepdog: add coroutine_fn markers to coroutine functions
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
cleanup qemu_co_sendv(), qemu_co_recvv() and friends
The same as for non-coroutine versions in previouspatches: rename arguments to be more obvious, changetype of arguments from int to size_t where appropriate,and use common code for send and receive paths (with...
sheepdog: fix return value of do_load_save_vm_state
bdrv_save_vmstate and bdrv_load_vmstate should return the vmstate sizeon success, and -errno on error.
sheepdog: mark image as snapshot when tag is specified
When a snapshot tag is specified in the filename, the opened image isa snapshot.
sheepdog: return -errno on error
On error, BlockDriver APIs should return -errno instead of -1.
sheepdog: use heap instead of stack for BDRVSheepdogState
bdrv_create() is called in coroutine context now, so we cannot usemore stack than 1 MB in the function if we use ucontext coroutine.This patch allocates BDRVSheepdogState, whose size is 4 MB, on the...
sheepdog: switch to writethrough mode if cluster doesn't support flush
This is necessary for qemu to work with the older version of Sheepdogwhich doesn't support SD_OP_FLUSH_VDI.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
aio: remove process_queue callback and qemu_aio_process_queue
Both unused after the previous patch.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: implement SD_OP_FLUSH_VDI operation
Flush operation is supposed to flush the write-back cache ofsheepdog cluster.
By issuing flush operation, we can assure the Guest of datareaching the sheepdog cluster storage.
Cc: Kevin Wolf <kwolf@redhat.com>...
sheepdog: fix send req helpers
We should return if reading of the header fails.
Cc: Kevin Wolf <kwolf@redhat.com>Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Liu Yuan <tailai.ly@taobao.com>Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
sheepdog: fix co_recv coroutine context
The co_recv coroutine has two things that will try to enter it:
1. The select(2) read callback on the sheepdog socket. 2. The aio_add_request() blocking operations, including a coroutine mutex.
This patch fixes it by setting NULL to co_recv before sending data....
prepare for future GPLv2+ relicensing
All files under GPLv2 will get GPLv2+ changes starting tomorrow.event_notifier.c and exec-obsolete.h were only ever touched by Red Hatemployees and can be relicensed now.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
move corking functions to osdep.c
sheepdog: move coroutine send/recv function to generic code
Outside coroutines, avoid busy waiting on EAGAIN by temporarilymaking the socket blocking.
The API of qemu_recvv/qemu_sendv is slightly different fromdo_readv/do_writev because they do not handle coroutines. It...
block: Add coroutine_fn marker to coroutine functions
Looks better when reviewing these source files.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: Avoid deadlock in error path
s->lock should be unlocked before leaving add_aio_request.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: add coroutine_fn markers
This makes the following patch easier to review.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: correct spelling
Reviewed-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
sheepdog: use coroutines
This makes the sheepdog block driver support bdrv_co_readv/writevinstead of bdrv_aio_readv/writev.
With this patch, Sheepdog network I/O becomes fully asynchronous. Theblock driver yields back when send/recv returns EAGAIN, and is resumed...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>