def METHOD_NAME(fd, magic):
    try:
        magic = int(magic, 0)
    except ValueError:
        print("'%s' is not a valid magic number" % magic)
        sys.exit(1)
    h = QcowHeader(fd)
    found = False
    for ex in h.extensions:
        if ex.magic == magic:
            found = True
            h.extensions.remove(ex)
    if not found:
        print("No such header extension")
        return
    h.update(fd)