From patchwork Wed Feb 10 23:09:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 78593 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1AN9gDi006142 for ; Wed, 10 Feb 2010 23:09:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755895Ab0BJXJa (ORCPT ); Wed, 10 Feb 2010 18:09:30 -0500 Received: from mail-fx0-f220.google.com ([209.85.220.220]:60452 "EHLO mail-fx0-f220.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755768Ab0BJXJ3 (ORCPT ); Wed, 10 Feb 2010 18:09:29 -0500 Received: by fxm20 with SMTP id 20so603565fxm.21 for ; Wed, 10 Feb 2010 15:09:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=tpI2wkblKnqiJPBQWI6NzNqZD4g/dkvjGVVgoNVZU/4=; b=A4VyGATD6zqtOXKHBOQtKheRhI1hmXxe79pLxtdos+rDsbnF3ddBdovBIz4yNQ3igq 1Wy6UCKF260HAqQheMPsCycsInEyT3Dj6leIzo+K8zMF8IMDw8mgy8XdD3q58/G7IGZo hJIqrjhPTjAviNboGaEOd6AtecKqDP8atCTNg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=tOAFURHcgVEB0O8MHqPJGdj0/l/P1EIpX32cmFr6t15RiUmbM7eIPIYKu3FnwtiyyY Pvjdq2d83t+h3W5rbIlvVOTRsHuKYWC6ScVexO0hd450PVRyVHmmTXNgMN5irC5cDbef 6iOfmKC+flWw/Na0M+RF1S3Wcjo+fXgWdGl8s= Received: by 10.223.75.15 with SMTP id w15mr1141998faj.70.1265843367727; Wed, 10 Feb 2010 15:09:27 -0800 (PST) Received: from localhost.localdomain ([85.93.118.17]) by mx.google.com with ESMTPS id 18sm2839148fks.34.2010.02.10.15.09.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Feb 2010 15:09:27 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Subject: [PATCH 1/4] qemu-kvm: morph qemu_kvm_notify_work into qemu.git's qemu_event_increment Date: Thu, 11 Feb 2010 00:09:13 +0100 Message-Id: <1265843356-25765-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> References: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Feb 2010 23:09:42 +0000 (UTC) diff --git a/qemu-kvm.c b/qemu-kvm.c index a305907..669a784 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1991,32 +1991,22 @@ int kvm_init_ap(void) void qemu_kvm_notify_work(void) { - uint64_t value = 1; - char buffer[8]; - size_t offset = 0; + /* Write 8 bytes to be compatible with eventfd. */ + static uint64_t val = 1; + ssize_t ret; if (io_thread_fd == -1) return; - memcpy(buffer, &value, sizeof(value)); - - while (offset < 8) { - ssize_t len; - - len = write(io_thread_fd, buffer + offset, 8 - offset); - if (len == -1 && errno == EINTR) - continue; - - /* In case we have a pipe, there is not reason to insist writing - * 8 bytes - */ - if (len == -1 && errno == EAGAIN) - break; - - if (len <= 0) - break; - - offset += len; + do { + ret = write(io_thread_fd, &val, sizeof(val)); + } while (ret < 0 && errno == EINTR); + + /* EAGAIN is fine in case we have a pipe. */ + if (ret < 0 && errno != EAGAIN) { + fprintf(stderr, "qemu_kvm_notify_work: write() filed: %s\n", + strerror(errno)); + exit (1); } }