Received: from eggs.gnu.org ([2001:4830:134:3::10]:33674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRanv-0004pT-W1 for qemu-devel@nongnu.org; Mon, 25 Jul 2016 04:00:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRanr-0006HJ-Ra for qemu-devel@nongnu.org; Mon, 25 Jul 2016 03:59:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRanr-0006Gu-LD for qemu-devel@nongnu.org; Mon, 25 Jul 2016 03:59:55 -0400 Date: Mon, 25 Jul 2016 09:59:50 +0200 From: Igor Mammedov Message-ID: <20160725095950.4280dd25@nial.brq.redhat.com> In-Reply-To: <87y44tr6fz.fsf@dusky.pond.sub.org> References: <1469008443-72059-1-git-send-email-imammedo@redhat.com> <878twv8k13.fsf@dusky.pond.sub.org> <20160721133958.00ae47c1@nial.brq.redhat.com> <87y44tr6fz.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.7] fix qemu exit on memory hotplug when allocation fails at prealloc time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: pbonzini@redhat.com, rth@twiddle.net, qemu-devel@nongnu.org, crosthwaite.peter@gmail.com On Fri, 22 Jul 2016 18:19:44 +0200 Markus Armbruster wrote: > Igor Mammedov writes: > > > On Thu, 21 Jul 2016 10:36:40 +0200 > > Markus Armbruster wrote: > > > >> Igor Mammedov writes: > [...] > >> > @@ -352,15 +352,14 @@ void os_mem_prealloc(int fd, char *area, size_t memory) > >> > for (i = 0; i < numpages; i++) { > >> > memset(area + (hpagesize * i), 0, 1); > >> > } > >> > + } > >> > > >> > - ret = sigaction(SIGBUS, &oldact, NULL); > >> > - if (ret) { > >> > - perror("os_mem_prealloc: failed to reinstall signal handler"); > >> > - exit(1); > >> > - } > >> > - > >> > - pthread_sigmask(SIG_SETMASK, &oldset, NULL); > >> > + ret = sigaction(SIGBUS, &oldact, NULL); > >> > + if (ret) { > >> > + perror("os_mem_prealloc: failed to reinstall signal handler"); > >> > + exit(1); > >> > >> I guess you're keeping the exit() here, because you can't recover > >> cleanly from this error. I should never happen anyway. Worth a > >> comment, I think. > > I didn't added comment because it's obvious that it's not possible > > to recover and also because it's just the same old code that haven't > > had a comment to begin with (probably also due to its obviousness) > > It's obvious enough once you read closely enough to see what the failing > code is doing. > > The old code uses perror() + exit() consistently. The new code mixes > Error with them, which is an anti-pattern. That's okay, the exit() is > perfectly fine here. The issue for me is that the anti-pattern triggers > the WTF-detector at a glance, but then I have to read closely to see #1 > it's intentional, and #2 it's okay. That wasn't the case before. > > [...] I'll post a patch to add comment on top of this one.