Received: from eggs.gnu.org ([2001:4830:134:3::10]:51580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQdB3-0006Vo-91 for qemu-devel@nongnu.org; Fri, 22 Jul 2016 12:19:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQdAz-0007No-3A for qemu-devel@nongnu.org; Fri, 22 Jul 2016 12:19:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQdAy-0007NS-Te for qemu-devel@nongnu.org; Fri, 22 Jul 2016 12:19:49 -0400 From: Markus Armbruster References: <1469008443-72059-1-git-send-email-imammedo@redhat.com> <878twv8k13.fsf@dusky.pond.sub.org> <20160721133958.00ae47c1@nial.brq.redhat.com> Date: Fri, 22 Jul 2016 18:19:44 +0200 In-Reply-To: <20160721133958.00ae47c1@nial.brq.redhat.com> (Igor Mammedov's message of "Thu, 21 Jul 2016 13:39:58 +0200") Message-ID: <87y44tr6fz.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Igor Mammedov Cc: pbonzini@redhat.com, rth@twiddle.net, qemu-devel@nongnu.org, crosthwaite.peter@gmail.com 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. [...]