From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPvQP-0006EA-Gc for qemu-devel@nongnu.org; Wed, 10 Apr 2013 09:51:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPvQF-0006Qm-Oc for qemu-devel@nongnu.org; Wed, 10 Apr 2013 09:50:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPvQF-0006Pq-EE for qemu-devel@nongnu.org; Wed, 10 Apr 2013 09:50:47 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3ADojoB017327 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Apr 2013 09:50:45 -0400 Message-ID: <51656E33.8050505@redhat.com> Date: Wed, 10 Apr 2013 15:50:43 +0200 From: Pavel Hrdina MIME-Version: 1.0 References: <877gkavlw2.fsf@blackfin.pond.sub.org> <516544C3.2060306@redhat.com> <516559EB.8020005@redhat.com> <20130410084025.5db97979@redhat.com> <51655FC7.4070804@redhat.com> <516567A9.5020303@redhat.com> <20130410093255.440005f7@redhat.com> In-Reply-To: <20130410093255.440005f7@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 00/11] convert savevm to use qapi and introduce qmp command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Markus Armbruster , qemu-devel@nongnu.org On 10.4.2013 15:32, Luiz Capitulino wrote: > On Wed, 10 Apr 2013 15:22:49 +0200 > Pavel Hrdina wrote: > >> On 10.4.2013 14:49, Eric Blake wrote: >>> On 04/10/2013 06:40 AM, Luiz Capitulino wrote: >>>> On Wed, 10 Apr 2013 06:24:11 -0600 >>>> Eric Blake wrote: >>>> >>>>>> - If you want to overwrite an existing snapshot, you could specify >>>>>> the 'id' or the 'name' argument or both of them and also you will >>>>>> have to use the 'force' argument >>>>> >>>>> But the argument made in this thread is that QMP should _not_ have a >>>>> force argument. It should be a flat-out error in QMP to try to create a >>>>> snapshot with a conflicting name or tag; preferably with a distinct >>>>> error type. Higher-level apps (HMP savevm -f) would try to create; if >>>>> -f is not specified, the error is good enough; if -f is specified and >>>>> that particular error is returned, then HMP calls delete and then >>>>> re-tries the create. No 'force' argument needed at the QMP layer. >>>> >>>> To avoid adding a new error class, the HMP command could query for the >>>> snapshot name and delete it if it exists before creating the snapshot. >>> >>> Atomic collision detection is nicer than having to pre-query - fewer QMP >>> calls in the common case. But you're right that none of the existing >>> ErrorClass categories fit the idea of "creation refused because name >>> would collide". > > We can add a new error class if it's important to be atomic. I don't think > this is hugely important though, first because we don't support multiple > QMP connections (it should work, but we don't advertise it as supported) and > also because I don't think we have ever designed commands with this in mind. > >> We still could have the force parameter for HMP because the QMP command >> will return an error message that the snapshot already exist. The only >> drawback will be that the error message will not contain an information >> that you could use a '-f' parameter for override. > > You're right, but we're discussing how the HMP command could detect that > an existing snapshot should be deleted. > If you will get an error about existing snapshot then you could write "savevm -f my_name" and the code could be something like this: if (force) { qmp_vm_snapshot_delete(!!name, name, false, 0, &local_err); if (error_is_set(&local_err) { hmp_handle_error(mon, &local_err); return; } } info = qmp_vm_snapshot_save(!!name, name, &local_err); if (info) { print_info } qapi_free_SnapshotInfo(info); hmp_handle_error(mon, &local_err); The only requirement is that the qmp_vm_snapshot_delete cannot set an error if the snapshot doesn't exist. To get this information the qmp_vm_snapshot_delete will return nothing or SnapshotInfo of deleted snapshot.